C#读写操作app.config中的数据
2012-11-07 09:09
531 查看
读语句:
写语句:
View Code
String str = ConfigurationManager.AppSettings["DemoKey"];
写语句:
View Code
///<summary> ///在*.exe.config文件中appSettings配置节增加一对键、值对 ///</summary> ///<param ></param> ///<param ></param> private static void UpdateAppConfig(string newKey, string newValue) { bool isModified = false; foreach (string key in ConfigurationManager.AppSettings) { if(key==newKey) { isModified = true; } } // Open App.Config of executable Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // You need to remove the old settings object before you can replace it if (isModified) { config.AppSettings.Settings.Remove(newKey); } // Add an Application Setting. config.AppSettings.Settings.Add(newKey,newValue); // Save the changes in App.config file. config.Save(ConfigurationSaveMode.Modified); // Force a reload of a changed section. ConfigurationManager.RefreshSection("appSettings"); }
相关文章推荐
- C#读写操作app.config中的数据应用介绍
- C#读写操作app.config中的数据应用介绍
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据(收藏)
- 【引用】C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C# App.config文件配置数据的读写
- [转]C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- C#读写app.config中的数据
- c# winform app.config xml 配置文件 读写操作
- C#读写app.config中的数据