{
try
{
string configPath = string.Format(@"{0}\{1}", _appStartPath, ConfigFile);
Configuration config = ConfigurationManager.OpenExeConfiguration(configPath);
txt_NoMsgInterval.Text = config.AppSettings.Settings["NoMsgInterval"].Value;
txt_WorkThreadCount.Text = config.AppSettings.Settings["WorkThreadCount"].Value;
txt_DbConnStr.Text = config.AppSettings.Settings["DbConnStr"].Value;
txt_ControlSrvPort.Text = config.AppSettings.Settings["ControlSrvPort"].Value;
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
}
private void SetConfig()
{
string key = "";
string value = "";
Configuration config = ConfigurationManager.OpenExeConfiguration(string.Format(@"{0}\{1}", _appStartPath, ConfigFile));//ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//
key = "NoMsgInterval";
value = txt_NoMsgInterval.Text.Trim();
// ConfigurationManager.AppSettings[key] = value;
//config.AppSettings[key] = value;
config.AppSettings.Settings[key].Value = value;
key = "WorkThreadCount";
value = txt_WorkThreadCount.Text.Trim();
config.AppSettings.Settings[key].Value = value;
//key = "DefaultDataStoreSrvIp";
//value = txt_DefaultDataStoreSrvIp.Text.Trim();
// ConfigurationManager.AppSettings[key] = value;
//key = "DefaultDataStoreSrvPort";
//value = txt_DefaultDataStoreSrvPort.Text.Trim();
// ConfigurationManager.AppSettings[key] = value;
key = "DbConnStr";
value = txt_DbConnStr.Text.Trim();
config.AppSettings.Settings[key].Value = value;
//key = "LogFilePath";
//value = txt_LogFilePath.Text.Trim();
// ConfigurationManager.AppSettings[key] = value;
key = "ControlSrvPort";
value = txt_ControlSrvPort.Text.Trim();
//config.AppSettings[key] = value;
config.AppSettings.Settings[key].Value = value;
//ConfigurationManager
//_acfghlp.SaveAppConfig();
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}