How to change in runtime application settings

rpf picture rpf · Feb 13, 2009 · Viewed 26.8k times · Source

I'm trying to change in runtime one key of my applications settings file, but it does not work.

I do on that way:

ConfigurationSettings.AppSettings["XPTO"] = "HELLO";

It seems that it only changes in memory, not on the file.

Does anyone knows how to do this?

Thanks.

Answer

el2iot2 picture el2iot2 · Feb 13, 2009

Take a look at my overview of .NET settings files...In short, I think you want a user-scoped setting. It will behave more like you expect.

Edit: If you are using the settings designer in Visual Studio, then simply change the "Scope" to "User". If not, you should be able to do the equivalent programmatically.