Monday, July 16, 2007

ConfigurationManager .Net

How you read your custom setting in your application configuration file.

//Read settings
public static string ReadConfig(string key)
{
return ConfigurationManager.AppSettings.GetValues(key)[0];
}

//Update Settings & get immediate changes
public static void SetConfig(string key, string value)
{
Configuration con = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
con.AppSettings.Settings[key].Value = value;
con.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection("appSettings");
}

2 comments:

Anonymous said...

Thanks, this was helpful. It's been so confusing working with the configuration manager since they keep changing thinggs.

Anonymous said...

Can anyone recommend the robust Remote Desktop program for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: [url=http://www.n-able.com] N-able N-central it management
[/url] ? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!