Accessing filesystem in Angular 2 app using Electron

前端 未结 5 1238
抹茶落季
抹茶落季 2021-01-02 11:00

I know that Angular 2 is run on a web browser, which does not have access to the file system.

However, I\'m using Electron as my front-end, and also running the app

5条回答
  •  -上瘾入骨i
    2021-01-02 11:39

    I'm late to the party but I also stumbled upon this problem recently. To the late comers, you can use ngx-fs

    https://github.com/Inoverse/ngx-fs

    Usage:

    const fs = this._fsService.fs as any;
    fs.readdir("\\", function (err, items) {
       if (err) {
          return;
       }
       for (let i = 0; i < items.length; i++) {
         console.log(items[i]);
       }
    });
    

提交回复
热议问题