且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用电子在本地保存文件

更新时间:2023-02-02 21:05:35

如果你面向多个平台,我回答了 这里有一个类似的问题.基本上 app.getPath(name), app.setPath(name, path)app.getAppPath() 对于将文件保存到正确的位置非常有用,而不管操作系统如何.

If you are targeting multiple platforms, I answered a similar question here. Basically app.getPath(name), app.setPath(name, path), and app.getAppPath() are very useful in saving files to the the right place regardless of the OS.

您可能还想查看这些 Nodejs 包,它们有助于简化将文件直接保存到主机的过程...

You may also want to check out these Nodejs packages which help simplify saving files directly to the host machine...

如果您打算让用户保存文件,您还可以查看 Dialog api 您可以在其中专门调用 保存对话框那个目的.

If you intend for users to save files you might also have a look at the Dialog api where you can specifically invoke a save dialog for that purpose.