fxx-wenjianjia-fan
v1.0.0
Published
这是删除文件和文件夹的方法 ```javascript const fs = require("fs"); const removeDir = (pathdir) => { //读取文件夹子目录 const arr = fs.readdirSync(pathdir); arr.forEach(item => { let middpathdir = pathdir + "/" + item; let info = fs.statSync
Downloads
3
Readme
这是删除文件和文件夹的方法
const fs = require("fs");
const removeDir = (pathdir) => {
//读取文件夹子目录
const arr = fs.readdirSync(pathdir);
arr.forEach(item => {
let middpathdir = pathdir + "/" + item;
let info = fs.statSync(middpathdir);
if (info.isFile()) {
fs.unlinkSync(middpathdir)
} else {
removeDir(middpathdir)
}
})
fs.rmdirSync(pathdir)
}
module.exports=removeDir;