【发布时间】:2019-03-05 14:34:24
【问题描述】:
学习 Electron 我想在drag and drop 之后做一些文件处理。在 Mac 上,tmp 的等价物是$TMPDIR。参考 app 的 API 文档,我能够找到 app.getAppPath(),它显示了我从 main.js 的简单控制台日志中获取的路径。在app.getAppPath() 下面有getPath() 但是当我尝试app.getPath(temp) 时:
let foobar = app.getAppPath("temp")
console.log(foobar)
我在以下控制台中收到错误:
ReferenceError: temp 未定义
通过我的研究,我读到了:
- How to store user data in Electron
- How to get the original path of a portable Electron app?
- 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")}`)
它返回与以下相同的响应:
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之后。
【问题讨论】:
标签: node.js electron temporary-files tmp