Ich muss Schlüsselwertpaare wie folgt in app.Config einfügen:
<configuration>
<appSettings>
<add key="Setting1" value="Value1" />
<add key="Setting2" value="Value2" />
</appSettings>
</configuration>
Als ich in Google gesucht habe, habe ich das folgende Code-Snippet erhalten
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);
Der obige Code funktioniert nicht, da ConfigurationManager nicht im System.Configuration-Namespace gefunden wird, den ich .NET 2.0 verwende. Wie füge ich Schlüssel-Wert-Paare programmgesteuert zu app.Config hinzu und rufe sie ab?