窗口设计 获取指定配置文件
ExeConfigurationFileMap exc = new ExeConfigurationFileMap();
string BasePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;//获取当前程序所在的目录
exc.ExeConfigFilename = BasePath + "YJKJ.Scan.JY.exe.config";//确认配置文件位置
XmlOperate xmlScanConfig = new XmlOperate(BasePath + "YJKJ.Scan.JY.exe.config");
string dz= BasePath + "YJKJ.Scan.JY.exe.config";
Configuration AppConfig = ConfigurationManager.OpenMappedExeConfiguration(exc, ConfigurationUserLevel.None);
//取值
string Temp = AppConfig.AppSettings.Settings["Temp"].Value;
this.Temp.Text = Temp;

获取本地配置文件内容
//string a = ConfigurationManager.AppSettings["Temp"];
编辑提交地址

private void AddUpdateAppSettings(string key, string value)
{
ExeConfigurationFileMap exc = new ExeConfigurationFileMap();
string BasePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
exc.ExeConfigFilename = BasePath + "YJKJ.Scan.JY.exe.config";
//Configuration AppConfig = ConfigurationManager.OpenMappedExeConfiguration(exc, ConfigurationUserLevel.None);
try
{
var configFile = ConfigurationManager.OpenMappedExeConfiguration(exc,ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
if (settings[key] == null)
{
settings.Add(key, value);
}
else
{
settings[key].Value = value;
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error writing app settings");
}
}
编辑配置文件
AddUpdateAppSettings("Temp", Temp.Text);
弹框
MessageBox.Show("保存成功!");
this.Close();//关闭窗口
单选按钮分组

根据值判断

根据按钮传值

combobox添加数组


浙公网安备 33010602011771号