Node.js CRUD with File System
const fs=require('fs');
const path=require('path');
const dirPath=path.join(__dirname, 'crud');
const filePath=`${dirPath}/apple.txt`;
// fs.writeFileSync(filePath, 'this is a apple.txt file');
// fs.readFile(filePath,'utf8', (err, item)=>{
// console.log(item)
// })
// fs.appendFile(filePath, 'I am updating apple.txt file', (err)=>{
// if(!err){
// console.log("file is updated")
// }
// })
// fs.rename(filePath, `${dirPath}/fruit.txt`, (err)=>{
// if(!err){
// console.log("File name has been renamed")
// }
// })
fs.unlinkSync(`${dirPath}/fruit.txt`)
Comments
Post a Comment