import path from "node:path";
import fsPromise from "node:fs/promises";
const filePath = path.resolve(import.meta.dirname, "./text/text.js");
fsPromise
.writeFile(filePath, "hello-word" + new Date().toDateString())
.then(() => {
console.log("写入成功");
});
async function test() {
const uid = (Math.random() * 10).toString(32);
const FilePath = path.resolve(import.meta.dirname, `./text/${uid}text.js`);
await fsPromise.writeFile(FilePath, "hello-word");
await fsPromise.stat(FilePath);
}
async function DeleteAllFiles() {
const filePath = path.resolve(import.meta.dirname, "./text");
const fileLists = await fsPromise.readdir(filePath);
fileLists.map((item) => {
fsPromise.unlink(path.resolve(filePath, item));
});
}
test()