Skip to content
Advertisement

Why is NW.SHELL only wokring in root DIR of app?

For some reason NW.SHELL fuctions are only working for files in root folder of my app. It wont let me use an absolute path or a relative path. Example “/relative/path/text.txt” or D:/relative/path/text.txt however text.txt will work with NW.SHELL function as long as the text file is in the same root DIR obviously.

This applies to both of these. What can i do to get relative or absolute paths to work? preferably relative paths. The nature of my program relative would be most functional.

nw.Shell.showItemInFolder('test.txt');
nw.Shell.openItem('test.txt');

Answer

Using version 0.65.0 of NW.js, it does work with absolute paths.

const path = require('path');
nw.Shell.openItem(path.resolve('./test.txt'));

If that doesn’t work, test.txt is not in the current working directory.

Advertisement