The application configuration file provides flexibility in reading application settings. But once in a while it is needed to change the settings programmatically.
We can see how it is made possible.
Step 1: Create new Windows Forms application
Create a new windows forms application and add a config file into it.
Step 2: Add reference to System.Configuration
Add reference to System.Configuration namespace
Step 3: Add code to edit config
System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
For editing an existing appSettings key – we have deleted and added the key.