I am trying to store my created file's path after using SaveFileDialog, here is my code:
let path;
dialog.showSaveDialog((fileName) => {
if (fileName === undefined){
console.log("You didn't save the file");
return;
}
fs.writeFile(fileName, text, (err) => {
if(err){
alert("An error ocurred creating the file "+ err.message)
}
alert("The file has been succesfully saved");
});
});
What I want to happen is that after the user creates the file he would enter file's path in the variable path, is it even possible?
this worked for me:
const { dialog } = require('electron')
dialog.showSaveDialog({
title: "Save file"
}).then((filePath_obj)=>{
if (filePath_obj.canceled)
console.log("canceled")
else
console.log('absolute path: ',filePath_obj.filePath);
});