我想知道是否有办法通过节点js打开文件夹位置。我找到this library但它只打开文件和网址。
编辑:Fuser的回答让我走上正轨,我发现了这个:
http://documentup.com/arturadib/shelljs
他或他的方法都可以。
答案 0 :(得分:0)
使用所需的文件夹向explore
发送消息。
答案 1 :(得分:0)
我还没有测试过这段代码,但这样的事情应该可以工作:
function dirOpen(dirPath) {
let command = '';
switch (process.platform) {
case 'darwin':
command = 'open';
break;
case 'win32':
command = 'explore';
break;
default:
command = 'xdg-open';
break;
}
console.log('execSync', `${command} "${dirPath}"`);
return execSync(`${command} "${dirPath}"`);
}