Electron open file/directory in specific application

You can open a file or folder through shell commands from the electron module. The commands work on both main and renderer process.

const {shell} = require('electron') // deconstructing assignment

shell.showItemInFolder('filepath') // Show the given file in a file manager. If possible, select the file.
shell.openPath('folderpath') // Open the given file in the desktop's default manner.

More info on https://github.com/electron/electron/blob/master/docs/api/shell.md

Leave a Comment

tech