将用户设置存储到应用程序文件夹中 [英] Store user settings into application folder
问题描述
我正在使用我的 C# 应用程序中的设置,如下所示:
I'm using setting from my C# application like this:
String str = Properties.Settings.Default.SETTINGS_NAME;
当我保存此设置时,会在
When I save this settings, a settings file is created on
C:\Documents and Settings\<user name>\Local Settings\Application Data\<comp name>\Keb.exe_Url_pbs4eg1o2ija22omldrwjxhdam0jxxi5\1.0.0.0\user.config
有没有办法将此路径更改为 Application.ExecutablePath\user.config
,并在下次使用它以便我的应用程序可以更便携?
Is there a way to change this path to Application.ExecutablePath\user.config
, and use it next time so my application can be more portable ?
推荐答案
您可以通过创建自定义 SettingsProvider
来控制 user.config
文件的位置.幸运的是,CodeProject 的某个人 已经这样做了.
You can control the location of the user.config
file by creating a custom SettingsProvider
. Luckily for you, someone at CodeProject already did that.
有关所有详细信息,请在此处查看我的答案:如何使设计器生成的 .Net 应用程序设置可移植
See my answer here for all the details: How to make designer generated .Net application settings portable
这篇关于将用户设置存储到应用程序文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!