PhantomJS - 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 
phantomjs_file_system_module_methods.htm
广告