Daniel
Daniel

Reputation: 709

How to 'open file with' electron.js app?

If the user right-clicks on a txt file he should me able to choose my app and the app should open the file.

My question is, how do I identify if the user has opened the app with a file and where is the file stored in the app?

In java, external parameters are stored in args[], does Electron have something like that?

Upvotes: 2

Views: 1054

Answers (1)

SomeBruh
SomeBruh

Reputation: 460

you can set the parameters by

electron main.js argv1 argv2

and then access the parameters by

const = require('electron').remote;
console.log(remote.process.argv);

and the output will be ["argv1", "argv2"]

Upvotes: 2

Related Questions