我需要添加关键数值。 概述如下:
<configuration>
<appSettings>
<add key="Setting1" value="Value1" />
<add key="Setting2" value="Value2" />
</appSettings>
</configuration>
当我用眼光进行搜查时,我看着以下法典。
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add an Application Setting.
config.AppSettings.Settings.Add("ModificationDate",
DateTime.Now.ToLongTimeString() + " ");
// Save the changes in App.config file.
config.Save(ConfigurationSaveMode.Modified);
The above code is not working as ConfigurationManager is not found in System.Configuration namespace I m using .NET 2.0. How to add key-value pairs to app.Config programatically and retrieve them?