How can I get the path that the application is running with typescript?

前端 未结 4 1004
孤独总比滥情好
孤独总比滥情好 2020-12-29 05:32

I am trying to create a desktop application with electron, angular2, typescript and neDB.In order to be able create a \'file\' database with neDB I want the path to my proje

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 06:03

    If you're running a packaged app and you want to get the path to the app executable (NOT the main Node process index script path, which could be inside an ASAR), app.getAppPath() is incorrect. You want app.getPath("exe"), and to get the path it's:

    require("path").dirname(require('electron').remote.app.getPath("exe"))
    

提交回复
热议问题