Skip to content

Instantly share code, notes, and snippets.

@pradeeprjth
Created February 18, 2022 13:13
Show Gist options
  • Save pradeeprjth/f21fc394109db8dbe7b2796cdfb3d2d3 to your computer and use it in GitHub Desktop.
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
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