/// <summary>
        /// 保存配置文件的设定
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="Value"></param>
        public static void SaveAppConfig(string Key,string Value)
        {
            string strFilePath = System.Windows.Forms.Application.ExecutablePath;
            Configuration objConfig = ConfigurationManager.OpenExeConfiguration(strFilePath);
            bool bolExist = false;
            foreach (string Item in objConfig.AppSettings.Settings.AllKeys)
            {
                if (Item == Key)
                {
                    bolExist = true;
                    break;
                }
            }
            if (bolExist)
            {
                objConfig.AppSettings.Settings.Remove(Key);
            }
            objConfig.AppSettings.Settings.Add(Key,Value);
            objConfig.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
        }

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-08-27
  • 2021-11-20
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案