Awesome q2a theme

How to specify the path to save the file on desktop nodejs?

0 like 0 dislike
43 views
Create app on electron.js using node, you need to save the file to your desktop, I need to know the way to your desktop. I.e. a person presses a button in the app, and automatically the file is saved to your desktop.
var fio = { data: [] }; fio.data.push({ name: crypt.encrypt(name), group: crypt.encrypt(group) }); var json = JSON.stringify(fio); if(!fs.existsSync('data.json')) { fs.writeFile('data.json', json, 'utf8'); } else { fs.unlink('data.json', function (err) { if(err) return console.log("failed to remove file"); fs.writeFile('data.json', json, 'utf8'); console.log('File written') }) }
by | 43 views

2 Answers

0 like 0 dislike
Native code to pull, if lazy with my native module to figure out the easiest way to take
\rhttps://www.npmjs.com/package/ffi
+
\rhttps://stackoverflow.com/questions/17933917/get-t...
by
0 like 0 dislike
https://electronjs.org/docs/api/app#appgetpathname
import {app} from 'electron'; console.log(app.getPath('desktop'));
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 11, 2019 by ff0xff
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users