PhantomJS 删除指定文件方法


发布日期 : 2020-06-19 12:49:06 UTC

访问量: 10 次浏览

PhantomJS remove删除

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