4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ElectronでWindows固有のファイルパスを得る

Posted at

progreさんのqiitaでまとめて頂いていたが、最新のElectronで試したらエラーなく表示できる範囲が替わっていた。
windowsの範囲を改めて調べてみました。

Electronで固有パスを得るには

メインプロセスを実行しているファイルで、app.getPath()に取得したいフォルダの固定名を引数を入れて実行する。

詳しくは、以下参照
https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname

固有パスを取得
const { app } = require('electron')
app.getPath(/*ここに取得したい固定名を入れる*/);

//実行例
console.log(app.getPath('home'));// C:\Users\【ユーザー名】
固定名 フォルダ パスの例
home ユーザホーム C:\Users\【ユーザー名】
appData ユーザーごとのアプリケーションデータディレクトリ(%APPDATA%のパス) C:\Users\【ユーザー名】AppData\Roaming
userData 起動アプリのアプリケーションディレクトリ C:\Users\【ユーザー名】\AppData\Roaming\【パッケージ名】】
cache (謎) C:\Users\【ユーザー名】\AppData\Roaming
temp 一時フォルダ C:\Users\【ユーザー名】\AppData\Local\Temp
exe 実行している.exeのパス 実行している.exeのパス
module 実行している.exeのパス 実行している.exeのパス
desktop デスクトップ C:\Users\【ユーザー名】\Desktop
documents ドキュメント C:\Users\【ユーザー名】\Documents
downloads ダウンロード C:\Users\【ユーザー名】\Downloads
music ミュージック C:\Users\【ユーザー名】\Music
pictures ピクチャ C:\Users\【ユーザー名】\Pictures
videos ビデオ C:\Users\【ユーザー名】\Videos
logs setAppLogsPathの設定値。デフォルト空文字 (エラー:electron6)
pepperFlashSystemPlugin Pepper Flash pluginのフルパス (エラー:electron6)
4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?