-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.ts
27 lines (22 loc) · 1.2 KB
/
renderer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const dialog = require('electron').remote.dialog
var ipc= require('electron').ipcRenderer;
ipc.on('save',function(event){
var content=(<HTMLTextAreaElement>document.getElementById("textarea")).value;
var fs = require('fs');
// Or with ECMAScript 6
const {dialog} = require('electron').remote;
// You can obviously give a direct path without use the dialog (C:/Program Files/path/myfileexample.txt)
dialog.showSaveDialog((fileName) => {
if (fileName === undefined){
console.log("You didn't save the file");
return;
}
// fileName is a string that contains the path and filename created in the save file dialog.
fs.writeFile(fileName, content, (err) => {
if(err){
alert("An error ocurred creating the file "+ err.message)
}
alert("The file has been succesfully saved");
});
});
});