https://msdn.microsoft.com/zh-cn/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx

ConfigurationManager.AppSettings 属性

 获取当前应用程序默认配置的 AppSettingsSection 数据。
public static NameValueCollection AppSettings { get; } 返回一个 NameValueCollection 对象,该对象包含当前应用程序默认配置的 AppSettingsSection 对象的内容。
表示可通过键或索引访问的关联 System.String 键和 System.String 值的集合。
一个 AppSettingsSection 对象包含的配置文件的内容 appSettings 部分。
 var appSettings = ConfigurationManager.AppSettings;
appSettings.Count
appSettings.AllKeys   NameValueCollection 中的所有键。
appSettings[key]  NameValueCollection 中具有指定键的项
var configFile = ConfigurationManager.OpenExeConfiguration(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);

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <appSettings>
    <add key="Setting1" value="May 5, 2014"/>
    <add key="Setting2" value="May 6, 2014"/>
  </appSettings>
</configuration>

最新文章

  1. 从零开始,DIY一个jQuery(1)
  2. 学习 opencv---(8)非线性滤波:中值滤波,双边滤波
  3. codeforces 742E (二分图着色)
  4. spirng线程池的配置与使用
  5. 第37讲:List的foldLeft、foldRight、sort操作代码实战
  6. 详解Winform里面的缓存使用
  7. web负载均衡
  8. 【gradle报错】error: package org.apache.http does not exist
  9. Android开发学习之Intent具体解释
  10. 找呀志_ContentResolver操作ContentProvider数据
  11. subversion-fundamental concepts
  12. Linux学习——Shell基础
  13. loadView
  14. SpringBoot HttpServletResponse Header Cookie输出问题
  15. 算法手记(2)Dijkstra双栈算术表达式求值算法
  16. 2553 ACM N皇后 回溯递归
  17. Navicat连接MySQL8.0亲测有效
  18. centos 安装thrift
  19. ISO7816之管脚定义
  20. Python 数值计算库之-[Pandas](六)

热门文章

  1. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals )D. Innokenty and a Football League(2-sat)
  2. POJ1861 Network(Kruskal)(并查集)
  3. 中文名: 交通事故责任认定, 英文名称: Traffic accident responsibility identification
  4. java中的3大特性之多态
  5. luogu P3368 【模板】树状数组 2
  6. [BZOJ2655]calc(拉格朗日插值法+DP)
  7. spring boot 2.x静态资源会被HandlerInterceptor拦截的原因和解决方法
  8. 在WPF中合并两个ObservableCollection
  9. delphi设计浮动窗口
  10. Zookeeper api增删改查节点