Web.Config in web applications and App.Config in the desktop application can come very handy to store and retrieve different configuration / user variables or settings. Reading from the config files is very easy:
However modifying config file will take extra lines of code. Below lines will update the key attribute by deleting previous entry and adding new entry in the config file:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(“Category”, “New Value”);
Note: You will need to add reference to System.Configuration namespace (using System.Configuration)
Also this will not work while debugging from Visual Studio. Run the .exe file from Release or Debug folder and it should work perfectly.