In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to delete files in nodejs fs". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to delete files by nodejs fs"!
Nodejs fs delete file method: 1, create a new JS file and import the fs module; 2, use the mkdirSync method to create a folder user;3, call the open () method in the fs module to open the file; 4, call the unlink method to delete the file.
This article operating environment: windows7 system, nodejs10.16.2 version, Dell G3 computer.
How does nodejs fs delete files?
The method of deleting files in the core module FS in nodejs:
Double-click to open the HBuilderX tool and create a new Web project with related templates inside
On the js folder, right-click to create a new JavaScript file, enter a file name, and click create
Open the newly created JS file, import the fs module, create a folder user using the mkdirSync method, and then call the writeFile method to write to the file
Next, call the open () method in the fs module to open the newly created file
Since the HBuilderX tool does not run the file corresponding to Node.js directly, copy the file to the HBuilder tool, and then run it directly
Open the js folder, you can find that the user folder is generated under the directory, and the data.txt file is generated under the folder.
Click and open data.txt, and you can find that this file has written content.
Finally, in the js file, call the unlink method, delete the file data.txt, and check to see if the file still exists
At this point, I believe you have a deeper understanding of "nodejs fs how to delete files", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.