views:

65

answers:

1

Hi,

When I use this to write to my app.config file:

Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["Wachtwoord"].Value = "Test";
config.Save();
ConfigurationManager.RefreshSection("appSettings");

I can read it again. But when i close and restart the program, the value of "Wachtwoord" has changed again to the old value.

Does anybody how I could fix this?

Thanks

+2  A: 

Are you sure that this has not been caused by Visual Studio overwriting your settings file when you build the project? The original settings file lives with your source code, whereas you run the application from your build output directory (e.g. bin\debug). You may be making changes to the copy in the build output directory when you run the application, which will make changes to the version there. When you rebuild the project, the settings file will be overwritten.

chibacity
Yes. This is my problem. Thanks for the quick anwser. I've put the file to "always cop" now like jason said and it works perfect. Thanks a lot everyone
rubentjeuh