为什么我的应用程序设置没有得到坚持? [英] Why are my application settings not getting persisted?

查看:139
本文介绍了为什么我的应用程序设置没有得到坚持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一些设置是用户范围。但由于某些原因,他们没有被保​​存到.exe.config文件与。我做到以下几点:

So I have some settings that are of the user scope. But for some reason, they are not being saved to the .exe.config file. I do the following:

    Properties.Settings.Default.Email="new@value.com";
    Properties.Settings.Default.Save();

不过,我的问题在debug文件夹的设置文件,它仍然是我在Visual Studio中设置默认。我这样做不对吗?

Yet I look at the settings file in the debug folder and it is still the default that I set in visual studio. Am I doing this wrong?

推荐答案

用户设置特定于用户,这样他们就不会得到保存回.exe.config文件与,它是系统范围。

User settings are specific to the user, so they wouldn't get saved back to the .exe.config file, which is system wide.

从的文档 LocalSettingsProvider

应用程序范围的设置和   默认的用户范围设置   存储在一个文件名为   application.exe.config,这是   在同一目录下创建   可执行文件。应用   配置设置为只读。   特定的用户数据存储在一个文件   名为 username.config ,储存在   对用户的主目录。

Application-scoped settings and the default user-scoped settings are stored in a file named application.exe.config, which is created in the same directory as the executable file. Application configuration settings are read-only. Specific user data is stored in a file named username.config, stored under the user's home directory.

因此​​,对于一个UserSettingsTest应用刚刚从VS我结束了的道路调试器(因此vshost位)下运行:

So for a UserSettingsTest application just run from VS under the debugger (hence the vshost bit) I ended up with a path of:

C:\Users\Jon\AppData\Local\UserSettingsTest
  \UserSettingsTest.vshost.e_Url_pdqoppugkz1vaawbhwkkcu5ibxpi2fgu
  \1.0.0.0\user.config

这篇关于为什么我的应用程序设置没有得到坚持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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