使用电子在本地保存文件 [英] Saving files locally with electron

查看:28
本文介绍了使用电子在本地保存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些模板文件,每个文件都包含几个变量字符串,我想用 Electron 构建一个非常简单的输入表单(https://www.electronjs.org/) 并且我想将合成的输出文件保存在用户的计算机上.

I have some template files that contain a few variable strings each, I'd like to build a very simple input form with Electron (https://www.electronjs.org/) and I want to save the composed output file on the user's computer.

有没有什么模块可以让 Electron 在本地保存文件?

Is there any module I can use to let Electron save files locally?

推荐答案

如果你面向多个平台,我回答了 这里有一个类似的问题.基本上 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.

这篇关于使用电子在本地保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆