I want to store images on the users computer, so I figure it should be stored in users data folder, as described here.
app.getPath(name)
name
. Returns String - A path to a special directory or file associated with name. On failure an Error is thrown. You can request the following paths by the name:
home
User's home directory
appData
Per-user application data directory, which by default points to:%APPDATA% on Windows $XDG_CONFIG_HOME or ~/.config on Linux ~/Library/Application Support on macOS
userData
The directory for storing your app's configuration files, which by default it is the appData directory appended with your app's name.- ...
This is what I think you're supposed to do:
const app = require('electron'); alert(app.getPath('userData'));
But I get "getPath is not a function". I am not sure where to put it. It does not work from my html file or the renderer file, and I'm not sure how to use it from the main file because that's not linked to the web page.
If you see an app. asar file, or something similar with the . asar suffix, it is most likely an Electron App. Windows: Open up the program files directory of the application you are wondering about, and check the file folder for any file with .
Electron doesn't have the strict limitation of data flow. You can store the data in localStorage, or store the data in main thread and expose it to global. Or, you can also use electron-store for simple key-value storage. When the application grows bigger and bigger, the data flow will become harder to maintain.
Since the remote
method is being considered deprecated, as shown here, I'd suggest you do this:
const {app} = require('electron'); console.log(app.getPath('userData'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With