生成后无法在Electron App中写入文件 [英] Cannot Write File in Electron App After Build

查看:159
本文介绍了生成后无法在Electron App中写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个重复性的问题,但是我找不到任何答案
我想将电子应用程序数据存储在本地json文件中
这很好用,但是打包和构建后不起作用
我试图在管理员中运行应用程序,但此操作不再起作用!

I know this is a repetitious question but i can't find any answer
I want to store my electron app data in a local json file
This works very good but after packaging and building it doesn't work
I tried to run app in administrator but that doesn't work again!

我不知道如何解决这个问题

i don't know how to solve this problem

有一种方法可以将数据存储在电子应用程序中无所谓

There is a way to store data in electron app No Matter How

谢谢

推荐答案

您将文件保存在哪里?除非您具有管理员访问权限,否则您将无法保存到某些目录,因为这将暴露书面应用程序的许多潜在安全漏洞.

Where are you saving this file? Unless you have admin access, you can't save to certain directories because that would expose a lot of potential security holes of written apps.

有一个,它允许您将数据保存在使用 app.getPath("; userData") .这是您需要使用的神奇路径, app.getPath("userData").如果您不将数据保存到此路径,则需要管理员权限.

There was a package written that allows you to save data in a file for your app, making use of the path of app.getPath("userData"). This is the magic path you need to be using, app.getPath("userData"). If you aren't saving your data to this path, you will require admin access.

该软件包虽然利用了过时的安全性做法,但是如果您仍希望通过更好的做法将电子数据保存到文件中(例如,使用IPC而不是我是《 nofollow noreferrer>模板的作者.

That package although makes use of outdated security practices, so if you want to still save your electron data to a file with better practices (ie. using IPC instead of the remote module), I'd recommend this template that I am an author of.

这篇关于生成后无法在Electron App中写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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