How to get the original path of a portable Electron app?

前端 未结 7 1829
伪装坚强ぢ
伪装坚强ぢ 2020-12-24 08:08

I have an Portable Electron App (packed with: electron-builder + asar, portable build) on Windows. I try to get the application path but it returns a path within the user\\t

相关标签:
7条回答
  • 2020-12-24 09:03

    As none of the methods above worked and I don't want to use an external lib for this, i tried following:

            if (!fs.existsSync("../images")) {
                fs.mkdirSync("./../images");            
            }
            return path.resolve("./../images/") + "/";
    

    You can use any directory that should exist at the top level or anywhere else. In my case I know that one level higher in the directory there must be a directory called "images".

    This solution worked in my case for DEV build and prod (packaged).

    Are there any drawbacks when using this approach?

    0 讨论(0)
提交回复
热议问题