-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs.js
More file actions
53 lines (43 loc) · 1.06 KB
/
fs.js
File metadata and controls
53 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const fs = require("fs");
const path = require("path");
const rootFolder = path.join(__dirname, "test");
const rootFile = path.join(rootFolder, "index.js");
// Create a Folder
// fs.mkdir(rootFolder, (err) => {
// if (err) {
// return console.log("Something went unexpected!");
// }
// console.log("Folder Created!");
// });
// Create a File
// fs.writeFile(
// rootFile,
// "console.log('hello')",
// (err) => {
// if (err) {
// return console.log("Something went unexpected!");
// }
// console.log("File Created!");
// }
// );
// Reading a File
// fs.readFile(rootFile, "utf-8", (err, data) => {
// if (err) {
// return console.log("Something went unexpected!");
// }
// console.log(data);
// });
// Remove a File
// fs.unlink(rootFile, (err) => {
// if (err) {
// return console.log("Something went unexpected!");
// }
// console.log("File Removed!");
// });
// Remove a Folder
fs.rmdir(rootFolder, (err) => {
if (err) {
return console.log("Something went unexpected!");
}
console.log("Folder Removed!");
});