PhantomJS - removeDirectory



此方法有助于删除给定的目录。

语法

其语法如下 −

var fs = require('fs'); 
fs.removeDirectory(path); 

实例

以下示例演示了 removeDirectory 方法的工作原理。

命令 - phantomjs removedirectory.js test

var fs = require('fs'); 
var system = require('system'); 
var path = system.args[1]; 

console.log("Creating new directory " + path); 
var md = fs.makeDirectory(path); 

console.log("Directory present : "+fs.isDirectory(path)); 
console.log("Removing directory "+path); 
var rd = fs.removeDirectory(path); 

console.log("Directory present "+fs.isDirectory(path)); 
phantom.exit();

以上程序生成以下 输出

Creating new directory test 
Directory present : true 
Removing directory test 
Directory present false 
phantomjs_file_system_module_methods.htm
广告