学习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)
我在以下控制台中收到错误:
通过研究,我读到:
在Electron中,是否有内置的temp目录可在所有操作系统上工作,或者是
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
测试。 最佳答案
app.getAppPath()
不带参数。
对于app.getPath(name)
,参数应为字符串"temp"
:app.getPath("temp")
。
关于node.js - 在Electron应用程序中,您如何引用温度路径?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55005208/