使用 Javascript 修改本地文件 [英] Modify a local file with Javascript

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

问题描述

我必须制作一个带有界面的本地应用程序.此应用程序应加载、修改并保存文本文件.

I must make a local app with an interface. This app should load text files, modify them, and save them.

界面我用html/css/js做的,app的核心只用js做的.

I made the interface with html/css/js, and the core of the app was made with js only.

目前,我使用输入加载文件,但为了保存它,浏览器让我下载它.我知道这是一项安全措施.

Currently, I load the file with an input, but to save it, the browser makes me download it. I know this is a security measure.

此应用不会上线.

我的问题是:我该怎么做才能用新文件直接替换加载的文件?

My question is : what can I do to replace directly the loaded file by the new one ?

  • 我可以在没有浏览器的情况下使用我的应用 (html/css/js) 吗?
  • 是否有允许我直接编辑本地文件的浏览器?
  • 有什么我想不到的解决方案吗?可能使用另一种语言与 js 通信?

谢谢.

推荐答案

如果你不需要你的应用在线,使用 Electron 您可以使用现有代码制作可执行文件(您将更改使用 Electron API 保存文件的方式).作为在您的系统上运行的程序,您将能够直接保存在文件系统上.

If you don't need your app to be online, with Electron you can make an executable using your existing code (you will have change how you're going to save the file using Electron APIs). Being a program running on your system, you'll be able to save directly on the file system.

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

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