学习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)

我在以下控制台中收到错误:



通过研究,我读到:
  • 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中,是否有内置的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/

    10-12 00:03
    查看更多