访问量: 10 次浏览
remove 方法用于删除指定的文件。
remove 语法如下 –
var fs = require('fs');
fs.remove(path);
以下示例展示了 remove 方法的工作原理。
命令-phantomjs
remove.js test.txt
var fs = require('fs');
var system = require('system');
var path = system.args[1];
var md = fs.isFile(path);
console.log("File is present : "+fs.isFile(path));
console.log("Removing file "+path);
var rd = fs.remove(path);
console.log("File is present "+fs.isFile(path));
phantom.exit();
以上程序生成了以下输出。
File is present: true
Removing file test.txt
File is present false