marcialwushu / angular-electron

Angular Desktop Apps with Electron
5 stars 0 forks source link

import node fs module for such operations. #1

Open marcialwushu opened 5 years ago

marcialwushu commented 5 years ago

https://stackoverflow.com/questions/50588614/perform-a-working-directory-listing-through-electron-app-angular5

marcialwushu commented 5 years ago

https://electronjs.org/docs/api/ipc-main

marcialwushu commented 5 years ago

https://github.com/LukasMarx/angular-electron/blob/master/electron/main.ts

marcialwushu commented 5 years ago

File System

Stability: 2 - Stable

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://nodejs.org/api/fs.html#fs_class_fs_readstream