In the last article, we saw how to use the app.config file, its hierarchy, and preference in picking the App settings. In this article, we will see updating the app.config file at runtime. The article example shows adding, deleting and updating a Key-Value entry in the appSettings Section of app.config file. Note, all the settings related to the App goes under the appSettings section.
In the above example, the result of the action performed on the App.config file is passed on to the user through the ‘Display Area’. To add (Button Marked as 5) a setting to the app.config file, the key and value should be keyed-in in the Setting Key, Setting Value text boxes marked as 2 and 3 in the screenshot. The user should mention the key in the Setting Key text box to get (Marker 6) the AppSetting entry from the ‘App.Config’. We show the retrieved key in the display area and in the Setting value. To adjust (Through button marker 7) an existing setting, the user will point out the existing key and changed value in the Setting Key and Setting Value, respectively. To delete (Marker 8) a key, the user will specify it in the Setting Key. Note we do all these actions at run time.