As @phuongle pointed out in the comments you want to use showOpenDialog()
. Something like this:
var remote = require('remote');
var dialog = remote.require('electron').dialog;
var path = dialog.showOpenDialog({
properties: ['openDirectory']
});
UPDATE: If the above isn’t working for your current Electron version, you should try more modern importing:
const {dialog} = require('electron').remote;
In addition, in order to use remote
, you need to set enableRemoteModule
when creating your window in your main process:
const myWindow = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
});