-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78188d3
commit fcb84e9
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const dirPath = path.join(__dirname , 'curd'); | ||
|
||
const filePath = `${dirPath}/hello.txt`; | ||
|
||
// Creating a file | ||
fs.writeFileSync(filePath , 'this is a simple text'); | ||
|
||
// reading the file | ||
fs.readFile(filePath , "utf8" , (err , item) => { | ||
console.log(item); | ||
}) | ||
|
||
// appending a file | ||
fs.appendFile(filePath , ' and this an apple.txt file' , (err) => { | ||
if(!err) | ||
console.log('file is updated'); | ||
} ); | ||
|
||
//renaming the file | ||
fs.rename(filePath , `${dirPath}/fruit.txt` , (err) => { | ||
if(!err) | ||
console.log('file name is updated') | ||
}); | ||
|
||
// deleting the file | ||
|
||
//fs.unlinkSync(`${dirPath}/fruit.txt`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a simple text and this an apple.txt file |