adspace


How we can close a file in node js?

Answer Posted / Simpy Kumari

In Node.js, you can close a file by calling the fs.close() method on the file stream object obtained using the fs.openSync() or fs.readFileSync() functions. Here's an example: `const fs = require('fs'); const fileStream = fs.openSync('./myfile.txt', 'r+'); // Perform operations... fs.closeSync(fileStream);`

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is node js losing popularity?

592


How we can read a file in node js?

572