Get Special folder Path in Electron


#1

Is there ways to query special folder path in electron ? for example, in windows, how do I get the public document folder ?


#2

app.getPath can be used for some of the special folders, e.g. for the user’s documents folder:

const {app} = require('electron')

app.getPath('documents')

I’m not sure how you’d get the Public Documents folder though.


#3

It does appears to me that it only gives folder that’s accessible per user. I ends up hard-coded for the time-being, but I am still hoping to have a better answer.

http://electron.atom.io/docs/api/app/

app.getPath(name)
name String
Retrieves 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 OS X
userData The directory for storing your app’s configuration files, which by default it is the appData directory appended with your app’s name.
temp Temporary directory.
exe The current executable file.
module The libchromiumcontent library.
desktop The current user’s Desktop directory.
documents Directory for a user’s “My Documents”.
downloads Directory for a user’s downloads.
music Directory for a user’s music.
pictures Directory for a user’s pictures.
videos Directory for a user’s videos.
pepperFlashSystemPlugin Full path to the system version of the Pepper Flash plugin.