我该如何解决应用范围设置为只读? [英] How do I get around application scope settings being read-only?

查看:302
本文介绍了我该如何解决应用范围设置为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么用呢,如果他们不能从它们的默认值改变呢?反问。

What use are they if they cannot be altered from their default values anyway? Rhetorical question.

首先,什么是规避系统的设置和写入的应用范围,直接设置文件(下一段的安全问题)的最佳方式?的XmlReader / XmlWriter的?

First, what's the best way to circumvent the Settings system and write to the application scope settings file directly (security issues in the next paragraph)? XmlReader/XmlWriter?

IIRC,如果一个应用程序试图写入它的Program Files文件夹,Windows Vista和7做一些魔术prevent这一点。我想我需要调用UAC提升,我必须把那个花哨的盾牌图标在我的应用程序的选项窗口的确定按钮等。链接到一个快速的如何做?

IIRC, if an application tries to write to its Program Files folder, Windows Vista and 7 does some magic to prevent that. I suppose I need to call UAC to elevate and I must put that fancy shield icon on my application's Options window's OK button and so on. Link to a quick how-to?

另外,你可以告诉我,我想要做的是愚蠢的,我别的地方干脆存储我的可变应用范围设置。

Alternatively, you may tell me that what I'm trying to do is stupid and I should store my alterable application scope settings somewhere else altogether.

推荐答案

如果您将其更改为用户设置,就可以在code被改变,当你调用保存(),他们将被保存到用户config文件在当前用户的本地设置文件夹中。

If you change them to "user" settings they can be changed in code, and when you call Save() they will be saved to a user.config file in the current users local settings folder.

显然,这意味着它们可以是对每个用户不同。一般情况下,全局应用程序设置是为每个用户相同的code不被修改,因为改变一个用户做其他会影响每个人(因此应用程序设置为只读)。

Obviously, this means they can be different for every user. Generally, global application settings that are the same for every user aren't modified in code because a change that one user makes will effect everyone else (hence the app settings are read only).

如果你不希望他们的用户范围,看看在<一个href=\"http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx\">ConfigurationManager类。这将允许你手动读取和写入.config文件。但要记住,在C:\\ Program Files文件\\文件夹被保护,普通用户将不能访问它(这将导致UAC提示或VISTA / WIN7失败)。仔细考虑你将如何处理它,记住任何改变一个app.config将影响到所有用户。

If you don't want them to be user scoped, take a look at the ConfigurationManager class. This will allow you to manually read and write to .config files. Remember though that the c:\program files\ folder is protected and normal users won't have access to it (this will result in UAC prompts or failure in vista/win7). Consider carefully how you will handle it, and remember that any change to an app.config will affect all users.

有在窗户没有位置的所有用户都保证有写权限。

There is no location in windows that all users are guaranteed to have write access to.

这篇关于我该如何解决应用范围设置为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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