Phantomjs-remove-method

提供:Dev Guides
移動先:案内検索

PhantomJS-削除

このメソッドは、指定されたファイルを削除するために使用されます。

構文

その構文は次のとおりです-

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();

上記のプログラムは、次の output を生成します。

File is present: true
Removing file test.txt
File is present false