在文件资源pipe理器中无法打开子目录? – Node.js
我不明白为什么我不能在Node.js中打开“我的文档”的子目录。
我目前的代码:
function fileExplorer() { var spawn = require('child_process').spawn, child = spawn('C:\\Windows\\explorer.exe', ["%userprofile%\\documents"]); }
完全正常工作来启动用户的“我的文档”文件夹。 但是,如果我想在“我的文档”里面打开一个目录,比如说“我的文档/附加资料”,以下是不起作用的:
function fileExplorer() { var spawn = require('child_process').spawn, child = spawn('C:\\Windows\\explorer.exe', ["%userprofile%\\documents\\extra stuff"]); }
我错过了什么? 请原谅我,如果我问的是什么问题,我有一个devise导向的大脑,更熟悉HTML,CSS和一些Javascript。
%USERPROFILE%
环境variables可以通过process.env.USERPROFILE
下的代码访问,所以你可以使用path.join(process.env.USERPROFILE, 'Documents/extra stuff')