I am creating a Method for Read and Add a Key and Value into Application
Configuration file using C#.net.So you call that method in your
program(where you want)
Read and Display an Application Configuration file using C#.net
Read and Display an Application Configuration file using C#.net
public static void ShowConfigsetting()
{
foreach (string key in ConfigurationManager.AppSettings)
{
string value = ConfigurationManager.AppSettings[key];
string result = "Keys :" + " " + key + " " + "Key value:" + " " + value;
MessageBox.Show(result);
}
}
Add a Key and Value into Application Configuration file using C#.net
{
foreach (string key in ConfigurationManager.AppSettings)
{
string value = ConfigurationManager.AppSettings[key];
string result = "Keys :" + " " + key + " " + "Key value:" + " " + value;
MessageBox.Show(result);
}
}
public static void AddintoConfigsetting(string appkeys,string appvalues)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(appkeys, appvalues);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSetting");
ShowConfigsetting();
}
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(appkeys, appvalues);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSetting");
ShowConfigsetting();
}