karansys
karansys

Reputation: 2719

Not able to resolve path in electron between pre and post packaging

I have two conditions, one is electron is able to fetch files before electron has packaged. But I am not able to fetch the same files after electron has packaged.

For Example, I use path.resolve to .ini file present in parent directory. When I build electron package it is built two directories below. And I want the built package to still use the same .ini file.

path.resolve(__dirname,'../design.ini');

**Pre Package **

C:\cygwin64\home\xyz\Dev\xyz\abc\parent_dir\design.ini

**Post Package **

C:\cygwin64\home\xyz\Dev\xyz\abc\parent_dir\win64\abc\resources\app.asar\design.ini

Please not I build with asar enabled, Since the paths are different between pre and post, files are not fetched

Upvotes: 1

Views: 725

Answers (2)

spring
spring

Reputation: 18487

I use `path.join`` and specify the specific path for internal assets – since I know it in advance and it isn't going to change:

var p1 = path.join(__dirname,'preferences", 'design.ini');

Haven't had any problems – even with asar enabled.

Upvotes: 2

Damien
Damien

Reputation: 4093

Did you try to use app.getPath() instead of path.resolve(...) ?

Upvotes: 1

Related Questions