Reputation: 390
I want to store and write the data to the local system file which is entered in the text box given in the electron window
Is it possible to achieve this using the electron App ?
Upvotes: 0
Views: 3895
Reputation: 5446
This can be achieved using the standard node.JS filesystem API:
var fs = require('fs');
var content = "sample text file content";
fs.writeFile("/folder/filename.txt", content, function(err) {
if(err) {
return console.log(err);
}
console.log("File succesfully saved to disk.");
});
The Node Filesystem API can be a bit overwhelming, you could check out helper packages like fs-jetpack, which offer some user-friendly abstractions.
Additionally, the Electron API offers a method called dialog.showSaveDialog to determine the filepath using a dialog window.
Upvotes: 2