Created
February 18, 2022 13:13
-
-
Save pradeeprjth/f21fc394109db8dbe7b2796cdfb3d2d3 to your computer and use it in GitHub Desktop.
Performing CRUD operation inside a folder named CRUD , Creating ,reading,updating,renaming,deleting using file system core module NodeJs
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
const fs = require('fs'); | |
const path = require('path'); | |
const dirPath = path.join(__dirname,'crud'); | |
const filePath = `${dirPath}/fruit.txt`; | |
// Create File Using File System | |
// fs.writeFileSync(filePath,'This is a simple text file'); | |
// Read file using File System | |
// fs.readFile(filePath,'utf8',(err,item)=>{ | |
// console.log(item); | |
// }); | |
//Update file using File System | |
// fs.appendFile(filePath,'Suwar ki maa doctor',(err)=>{ | |
// if(!err) console.log("File Updated"); | |
// }) | |
//Rename File using FIle system | |
// fs.rename(filePath, `${dirPath}/fruit.txt`,(err)=>{ | |
// if(!err) console.log("File Renamed"); | |
// }); | |
//Delete file using FIle system | |
// fs.unlinkSync(`${dirPath}/fruit.txt`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment