1/// <summary> 2 /// 保存配置文件的设定 3 /// </summary> 4 /// <param name="Key"></param> 5 /// <param name="Value"></param> 6 public static void SaveAppConfig(string Key,string Value) 7 { 8 string strFilePath = System.Windows.Forms.Application.ExecutablePath; 9 Configuration objConfig = ConfigurationManager.OpenExeConfiguration(strFilePath); 10 bool bolExist = false; 11 foreach (string Item in objConfig.AppSettings.Settings.AllKeys) 12 { 13 if (Item == Key) 14 { 15 bolExist = true; 16 break; 17 } 18 } 19 if (bolExist) 20 { 21 objConfig.AppSettings.Settings.Remove(Key); 22 } 23 objConfig.AppSettings.Settings.Add(Key,Value); 24 objConfig.Save(ConfigurationSaveMode.Modified); 25 ConfigurationManager.RefreshSection("appSettings"); 26 }
C#编辑EXE使用的appSettings节点的Config文件
Stella981
2021-10-11
1033 0 0
点赞
收藏
评论区
加载中...