我的C#应用​​程序应该在哪里写入数据,使用户无法修改或访问 [英] Where should my c# application write data so that the user can not modify or access it

查看:138
本文介绍了我的C#应用​​程序应该在哪里写入数据,使用户无法修改或访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要存储用户信息的应用程序,如用户名和得分有等...
我选择了Environment.SpecialFolder枚举的LocalApplicationData。
,但我可以用手动文件浏览器,并可以编辑或删除,可以证明自己是一个弱点应用程序的文件和用户可能会乱用我的应用程序访问该目录为我的应用程序。



那么,有没有办法,我可以写使用代码,用户将无法访问任何目录。
TNX


解决方案

有没有办法,我可以写使用代码的任何目录用户将不能够访问它




没有。由用户帐户运行的应用程序具有相同的特权和权限用户。因此,没有办法,应用程序可以做一些用户不能对自己做的。



如果你需要存储的数据被用来浏览或用户修改,它应该在 Environment.SpecialFolder.Personal



另外,数据应该存储在或者(如果它应与用户账号漫游) Environment.SpecialFolder.ApplicationData Environment.SpecialFolder.LocalApplicationData (如果它应该的的漫游与用户,而是应该限制在本地机器)。



是,用户可以进入这些文件夹和破坏数据。通过这样做,他们跑破你的应用程序的风险。你无法从自己的安全自己。



制定一个修复实用工具,可以在必要时重新创建你的应用程序启动所需的文件从伤害中恢复过来。


I have an Application that needs to store User Info such as their Username and there score and etc... I have selected LocalApplicationData of the Environment.SpecialFolder Enumeration. but I can access the directory for my application manually using file explorer and can edit or delete the file that can prove as a weak spot for the application and the users may be able to mess with my application.

So, Is there any directory that I can write to using code that the user will not be able to access it. tnx

解决方案

Is there any directory that I can write to using code that the user will not be able to access it.

No. An application run by a user account has the same privileges and permissions as that user. Therefore, there is no way that the application could do something the user couldn't do on his own.

If the data you need to store is intended to be browsed or modified by the user, it should go in Environment.SpecialFolder.Personal.

Otherwise, data should be stored in either Environment.SpecialFolder.ApplicationData (if it should roam with the user account) or Environment.SpecialFolder.LocalApplicationData (if it should not roam with the user, and instead should be limited to the local machine).

Yes, the user can get into these folders and destroy the data. By doing so, they run the risk of breaking your application. You can't secure yourself from yourself.

Develop a "repair" utility that can recover from the damage by recreating the necessary files on startup of your application if necessary.

这篇关于我的C#应用​​程序应该在哪里写入数据,使用户无法修改或访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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