Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my application settings not getting persisted?

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();

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?

like image 624
ryeguy Avatar asked Jun 28 '09 06:06

ryeguy


1 Answers

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

From the docs of LocalSettingsProvider:

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.

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
like image 163
Jon Skeet Avatar answered Oct 05 '22 15:10

Jon Skeet