在 Electron 应用程序中,您如何引用临时路径?
In Electron app how do you reference the temp path?
学习 Electron 我想在 drag and drop. On a Mac the equivalent for tmp is a $TMPDIR
. Referencing the API documentation of app
I was able to locate the app.getAppPath()
which shows my path from a simple console log from main.js. Below app.getAppPath()
there is getPath()
之后做一些文件处理,但是当我尝试 app.getPath(temp)
:
let foobar = app.getAppPath("temp")
console.log(foobar)
我在控制台中收到错误:
ReferenceError: temp is not defined
通过我的研究,我读到了:
- How to store user data in Electron
- Creating and Using Temporary Files
- Get Special folder Path in Electron
- electron temp directory
- How to set a custom path for Electron app installer
在 Electron 中是否有一个内置的临时目录可以在所有操作系统上工作或 process
以供参考?
注:
即使在引用字符串之后:
console.log(`The temp path is: ${app.getAppPath("temp")}`)
它 returns 与以下响应相同:
console.log(`The AppPath is: ${app.getAppPath()}`)
即:
The temp path is: /Users/Grim/Documents/GitHub/electron-quick-start-boilerplate
The AppPath is: /Users/Grim/Documents/GitHub/electron-quick-start-boilerplate
和上面的 console.log
测试已添加到 letWindow
之后。
app.getAppPath()
不接受争论。
对于app.getPath(name)
,参数应该是字符串 "temp"
: app.getPath("temp")
.
学习 Electron 我想在 drag and drop. On a Mac the equivalent for tmp is a $TMPDIR
. Referencing the API documentation of app
I was able to locate the app.getAppPath()
which shows my path from a simple console log from main.js. Below app.getAppPath()
there is getPath()
之后做一些文件处理,但是当我尝试 app.getPath(temp)
:
let foobar = app.getAppPath("temp")
console.log(foobar)
我在控制台中收到错误:
ReferenceError: temp is not defined
通过我的研究,我读到了:
- How to store user data in Electron
- Creating and Using Temporary Files
- Get Special folder Path in Electron
- electron temp directory
- How to set a custom path for Electron app installer
在 Electron 中是否有一个内置的临时目录可以在所有操作系统上工作或 process
以供参考?
注:
即使在引用字符串之后:
console.log(`The temp path is: ${app.getAppPath("temp")}`)
它 returns 与以下响应相同:
console.log(`The AppPath is: ${app.getAppPath()}`)
即:
The temp path is: /Users/Grim/Documents/GitHub/electron-quick-start-boilerplate
The AppPath is: /Users/Grim/Documents/GitHub/electron-quick-start-boilerplate
和上面的 console.log
测试已添加到 letWindow
之后。
app.getAppPath()
不接受争论。
对于app.getPath(name)
,参数应该是字符串 "temp"
: app.getPath("temp")
.