Nothing is everything.

Wednesday, December 16, 2009

How to modify the app.config during runtime.

This is the code:

// Open App.Config of executable
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

// Add an Application Setting.
config.AppSettings.Settings.Add("Modification Date",
DateTime.Now.ToLongTimeString() + " ");

// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);

// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");



The link below shows the details:

No comments:

Post a Comment

Followers