- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- 網路伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他
- 命令列介面
- PhantomJS - 螢幕截圖
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - removeTree
removeTree 方法用於刪除給定資料夾中的所有檔案和資料夾,最後刪除資料夾本身。如果執行此過程時出現任何錯誤,它會丟擲以下錯誤 -“無法刪除目錄樹 PATH”並掛起執行。
語法
其語法如下 –
fs.removeTree(foldertodelete)
示例
以下示例顯示了 **removeTree** 方法如何工作。
var fs = require('fs');
var system = require('system');
var path = system.args[1];
console.log("Directory present : "+fs.isDirectory(path));
var a = fs.list(path);
console.log("Listing the contents from the directory : " + JSON.stringify(a));
console.log("Removing directory "+path);
var rd = fs.removeTree(path);
console.log("Directory present "+fs.isDirectory(path));
phantom.exit();
上述程式產生了以下 **輸出**。
Directory present : true Listing the contents from the directory : [".","..","examples","newfiles"] Removing directory removetree Directory present false
phantomjs_file_system_module_methods.htm
廣告