Open marcialwushu opened 5 years ago
The fs module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.
To use this module:
const fs = require('fs');
All file system operations have synchronous and asynchronous forms.
The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.
const fs = require('fs');
fs.unlink('/tmp/hello', (err) => {
if (err) throw err;
console.log('successfully deleted /tmp/hello');
});
Exceptions that occur using synchronous operations are thrown immediately and may be handled using try/catch, or may be allowed to bubble up.
const fs = require('fs');
try {
fs.unlinkSync('/tmp/hello');
console.log('successfully deleted /tmp/hello');
} catch (err) {
// handle the error
}
https://stackoverflow.com/questions/50588614/perform-a-working-directory-listing-through-electron-app-angular5