如何更改Electron存储(缓存、崩溃记录等)的路径?

huangapple go评论70阅读模式
英文:

How could I change path of electron storages(cache, crashpad, etc)

问题

I have been developing an app using electron, and I am trying to make it as portable as possible (and easily accessible to app data).

So I'm wondering if it's possible to change the paths of where electron stores the data to something like documents or even inside the app's folder (instead of %appdata%)

Thanks in advance

英文:

I have been developing an app using electron, and I am trying to make it as portable as possible (and easily accessible to app data).

So I'm wondering if it's possible to change the paths of where electron stores the data to something like documents or even inside the app's folder (instead of %appdata%)

Thanks in advance

答案1

得分: 1

为了使您的Electron应用程序在不同操作系统之间更加便携,您应该使用Electron可以访问的操作系统默认路径,例如用户的home目录、documents目录,或更好地使用您的应用程序的appData目录。

请查看Electron的app.getPath(name)app.setPath(name, path)方法以获取更多信息。

注意:在应用程序文件夹内直接存储任何形式的数据都是一个不好的主意。虽然可以进行"相对"数据引用,但应用程序更新会覆盖(即删除)其中存储的任何数据。

英文:

To make your Electron application portable, especially between operating systems, you should use the operating system default paths accessible by Electron, such as the users home directory, documents directory or better still your applications appData directory.

See Electrons app.getPath(name) and app.setPath(name, path) methods for more information.

> Note: It is a bad idea to store any form of data directly within the applications folder. Whilst "relative" referencing the data may be possible, an application update will overwrite (IE: delete) any data stored within.

huangapple
  • 本文由 发表于 2023年4月13日 19:59:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005155.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定