node.js 判断文件或者目录是否存在

来源:互联网 发布:天刀白玉京捏脸数据 编辑:程序博客网 时间:2024/06/11 05:46

用到node.js的模块fs中的accessSync函数

var path = '/home/debug/';

try{

fs.accessSync(path,fs.F_OK);

console.log('the file was already existed.');

}catch(e)

{

    console.log('the file not exist...');

}


阅读全文
0 0