.NET 2.0 modifying content of app.config file (C#)
Before you start, make sure you have added reference to System.Configuration.dll for .NET 2.0. I think the default the Visual Studio C# Express referenced to is from .NET 1.1 which will not compile. using System.Configuration; using System.Collections.Specialized; //to write System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("myKey"); config.AppSettings.Settings.Add("myKey", "123"); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); //to read NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings; string strRead = (string)appSettings["myKey"]; Content of app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myKey" value = "123"/> </appSettings...