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


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
13 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 | 13 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,186 answers
0 comments
36,596 users