I want to get the user data default directory of the application, i can get it from the main process easly but i can't access it from the render process. I have used the following for the render process based on link but it didn't work.
// If not already defined...
const { remote } = require ('electron');
const path = require ('path');
let execPath;
execPath = path.dirname (remote.app.getPath ('userData'));
// or
execPath = path.dirname (remote.process.execPath);//even this is returning the same error
it is giving me an error that remote is undefined
. I have tried accessing the app
directly like in the main process app.getPath('userData')
but it is still returning the same error. Is there a way to access the userData
folder path from the render process? or if there is a way to share it in a variable from the main process, it would be good.
I used electron-app-settings
and set it in a settings promise but it is returning an object and i can't use it in the download function that follows:
ipcRenderer.send("download", {
url: "download url",
properties: { directory: dir}
});
The error that i am getting is: Uncaught Error: An object could not be cloned. at EventEmitter.i.send (electron/js2c/renderer_init.js:73)
I am using electron-dl