如何改变.NET用户设置的位置 [英] how to change .NET user settings location

查看:226
本文介绍了如何改变.NET用户设置的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下设置存储于: C:\Documents和Settings\\Local Settings\Application Data\<项目名称>

By default settings are stored at: C:\Documents and Settings\\Local Settings\Application Data\<Project Name>

我怎样才能改变这种路径应用程序目录。我也不想对不同的用户不同的文件。如何使设置全球性的?

How can I change this path to application directory. I also don't want to have different files for different users. How make the settings global?

我试图改变的设置范围为应用程序,但我就不能在运行时改变它们。

I tried to change the scope of the settings to "application" but then I cannot change them at runtime.

推荐答案

使用默认的内置行为,你不能!

问:为什么是路径那么晦涩难懂?有什么办法来改变/定制

?答:的路径构造算法必须满足一定的在安全性,
隔离和稳健性方面的严格
的要求。虽然我们
试图使路径通过利用$友好的,应用程序提供
串的B $ b以容易
可发现如可能的话,不可能保持
中的路径完全简单而不运行到像碰撞
与其他应用程序,欺骗等问题

A: The path construction algorithm has to meet certain rigorous requirements in terms of security, isolation and robustness. While we tried to make the path as easily discoverable as possible by making use of friendly, application supplied strings, it is not possible to keep the path totally simple without running into issues like collisions with other apps, spoofing etc.

LocalFileSettingsProvider并不
提供了一种方式改变这些设置保存在
的文件。请注意,
为运营商本身并没有确定
第一
座的配置文件的位置 - 它是配置
系统。如果你需要存储在不同的位置为
某种原因,
设置,推荐的方法是
写自己的SettingsProvider。这种
是实现非常简单,你
可以发现在.NET 2.0 SDK
样本显示如何做到这一点。请记住,
然而,你可能会遇到上述同样的
隔离的问题。

The LocalFileSettingsProvider does not provide a way to change the files in which settings are stored. Note that the provider itself doesn't determine the config file locations in the first place - it is the configuration system. If you need to store the settings in a different location for some reason, the recommended way is to write your own SettingsProvider. This is fairly simple to implement and you can find samples in the .NET 2.0 SDK that show how to do this. Keep in mind however that you may run into the same isolation issues mentioned above .

我同意罗伯特·哈维的回答自己动手,或编写自定义设置提供。

I agree with Robert Harvey's answer do it yourself, or write a custom settings provider.

这篇关于如何改变.NET用户设置的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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