I am making an electron app that converts data from .txt files to Javascript arrays. This data is stored inside a folder called faces
in the main directory. I also have a button in my app which, when clicked opens file explorer at the faces
folder so the user can edit the .txt files. This works fine when running npm start
, but then when I use electron builder to package my app, the app can no longer find the .txt files and the user cannot edit them (giving me lots of errors). Is there some way to have a folder of .txt files that the app uses to draw information from with Electron builder?
Edit
Below is the JS used:
//Import Lists from .txt files
var ears = fs.readFileSync('faces/ears.txt', 'utf8').split('\n');
var mouths = fs.readFileSync('faces/mouths.txt', 'utf8').split('\n');
var eyes = fs.readFileSync('faces/eyes.txt', 'utf8').split('\n');
//Opens faces txt docs in file explorer
function edit() {
shell.openItem(require('electron').remote.app.getAppPath() + '/faces')
}
Here is what happens when I open the packaged app (this is the win-unpacked result but the error is the same for .exe which runs with the installer):
https://i.sstatic.net/sVtwF.jpg
As you can see it does not load an information and you can see it cannot find the faces
folder or the .txt files.