如何检查文件(由完整路径给出)是否存在?节点js

时间:2012-01-12 20:08:14

标签: node.js filesystems

我以为我可以用'fs'模块做到,但我找不到合适的功能。

2 个答案:

答案 0 :(得分:2)

fs = require('fs');        
fs.exists(path, function( exists ) {        
    console.log( ( exists  ? "File is there" : "File is not there" ) );         
});

答案 1 :(得分:0)

请参阅documentation for the fs module,特别是“stat”系列函数(stat,fstat,lstat,statSync,fstatSync,lstatSync)。

相关问题