- PhantomJS - Home
- PhantomJS - Overview
- PhantomJS - Environment Setup
- PhantomJS - Object
- PhantomJS - Methods
- PhantomJS - Properties
- PhantomJS - Methods
- PhantomJS - Events/Callbacks
- PhantomJS - Child Process Module
- File System Module
- PhantomJS - Properties
- PhantomJS - Methods
- System Module
- PhantomJS - Properties
- Web Server Module
- PhantomJS - Properties
- PhantomJS - Methods
- Miscellaneous
- Command Line Interface
- PhantomJS - Screen Capture
- PhantomJS - Page Automation
- PhantomJS - Network Monitoring
- PhantomJS - Testing
- PhantomJS - REPL
- PhantomJS - Examples
- PhantomJS Useful Resources
- PhantomJS - Quick Guide
- PhantomJS - Useful Resources
- PhantomJS - Discussion
PhantomJS - remove
This method is used to remove a specified file.
Syntax
Its syntax is as follows −
var fs = require('fs');
fs.remove(path);
Example
The following example shows how the remove method works.
Command − 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();
The above program generates the following output.
File is present: true Removing file test.txt File is present false
phantomjs_file_system_module_methods.htm
Advertisements