File System Module
File I/O is encapsulated by standard POSIX functions and requires access to the module using the Require (' FS ')
All of these methods provide both asynchronous and synchronous approaches.
1. Renaming files
var base_dir = __dirname; Copied.
2. modify file permissions and file permission properties
3. Get file meta information
4. Read file data
Fs.realfile (Path,[callback])
5. Verify that the file exists
Fs.exists (Path,[callback])
6. deleting files
Fs.unlink (Path,[callback])
The callback function has only one exception parameter, err
7. File reading and writing
Fs.write (Fd,buffer,offset,lenght,position,[callback]);
FD: Reading data from an FD file
Buffer:buffer buffers
Offset: Address to write to the buffer
Length: Number of data bytes pre-read
Position: Integer variable that identifies the starting position at which to read the file,
If NULL, writes are started from the current position.
[Callback]:(Err,written), how many bytes of data have been written.
Fs.read (Fd,buffer,offset,lenght,position,[callback]);
The buffer parameter can be created by using new buffer in node. js Bufferapi.
Web application file Processing for node. js