table of Contents
fs.stat checks whether it is a file or a folder
fs.writeFile creates a write file
First generate a package.json file, command: npm init
fs.stat checks whether it is a file or a folder
fs.mkdir new folder
Create a new multi-level folder, see: https://blog.csdn.net/qq_40323256/article/details/110944129
fs.writeFile creates a write file
If this file does not exist before, then this file will be created; if this file already exists, then the contents of the file will be replaced
Namely: if no, then create a new; if yes, then overwrite
As you can see, the test.txt file has been created. If the writeFile function is executed for the test.txt file at this time, the file will be replaced, as follows
fs.appendFile append file
If no, then create; if yes, then add
Append as follows:
fs.readFile read file
In addition, you can directly add "utf-8" without the toString() method, as follows:
fs.readdir read folder
fs.rename rename/move file
Move files
fs.unlink delete file
fs.rmdir delete folder
The folder to be deleted must be an empty folder!