Properties.Settings.Default存储在哪里? [英] Where are the Properties.Settings.Default stored?

查看:220
本文介绍了Properties.Settings.Default存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我知道这一点,但是今天又被证明是错的。

I thought I knew this, but today I'm being proven wrong - again.

运行VS2008,.NET 3.5和C#。我使用默认值将用户设置添加到属性设置选项卡,然后使用以下代码阅读它们:

Running VS2008, .NET 3.5 and C#. I added the User settings to the Properties Settings tab with default values, then read them in using this code:

myTextBox.Text = Properties.Settings.Default.MyStringProperty;

然后,在用户在选项对话框中编辑值之后,我将其保存为:

Then, after the user edits the value in the options dialog I save it like this:

Properties.Settings.Default.MyStringProperty = myTextBox.Text;
Properties.Settings.Default.Save();

我的问题是,这个新值保存在哪里?可执行文件目录中的MyApp.exe.config文件未更新,但仍包含默认值。另外,据我所知,该目录中的其他文件也没有更新!但是,当程序读回值时,它将获得更改后的值,所以我知道它已保存在某处...

My question is, where is this new value saved? the MyApp.exe.config file in the executable directory is not updated, it still contains the default values. Plus, as far as I can tell, none of the other files in that directory are updated either! However, when the program reads the value back in, it gets the changed value, so I know it's saved somewhere...

这不仅是学术上的,我需要以便能够在今天早上手动编辑值并在找不到任何更改的情况下陷入困境。

This isn't just academic, I needed to be able to manually edit the value this morning and got myself stumped when I couldn't find anything that was changing.

推荐答案

为了使用Windows的较新版本的策略,该策略默认情况下仅允许对Program Files文件夹进行读取访问(除非您提示使用UAC进行提升,但这是另一个主题...),您的应用程序将在%userprofile%\appdata\local %userprofile%\Local Settings\Application Data 取决于哪个版本您正在运行的Windows的用户特定设置。如果您存储所有用户的设置,则它们将位于 C:\users C:\Documents and Settings下的相应文件夹中用于所有用户个人资料(例如: C:\users\public\appdata\local )。

In order to work with newer versions of Windows' policy of only allowing read access by default to the Program Files folder (unless you prompt for elevation with UAC, but that's another topic...), your application will have a settings folder under %userprofile%\appdata\local or %userprofile%\Local Settings\Application Data depending on which version of Windows you're running, for settings that are user specific. If you store settings for all users, then they'll be in the corresponding folder under C:\users or C:\Documents and Settings for all user profiles (ex: C:\users\public\appdata\local).

这篇关于Properties.Settings.Default存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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