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>

ConfigurationManager.AppSettings 属性 appSettings的更多相关文章

  1. c#修改config中的AppSettings属性

    Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfa.AppS ...

  2. ConfigurationManager.ConnectionStrings 属性

    public static ConnectionStringSettingsCollection ConnectionStrings { get; } App.config <?xml vers ...

  3. ConfigurationManager.AppSettings方法

    一 配置文件概述: 应用程序配置文件是标准的 XML 文件,XML 标记和属性是区分大小写的.它是可以按需要更改的,开发人员可以使用配置文件来更改设置,而不必重编译应用程序.配置文件的根节点是conf ...

  4. ConfigurationManager 读写AppSettings键值对

    using System; using System.Configuration; namespace ConsoleApplication1 { class Program { static voi ...

  5. ConfigurationManager.AppSettings Property

    在app.config文件中添加如下配置 <appSettings> <add key="Server" value="127.0.0.1"/ ...

  6. AppSettings和connectionStrings的却别(转)

    AppSettings是ASP.NET1.1时期用的,在.NET Framework 2.0中,新增了ConnectionStrings. 1.<connectionStrings> &l ...

  7. <connectionStrings> <appSettings> 读取方法

    C#中ConnectionStrings和AppSettings的区别 时间 2013-03-07 15:57:00  博客园精华区 原文  http://www.cnblogs.com/bindot ...

  8. [转载]AppSettings和ConnectionStrings的区别

    AppSettings是ASP.NET1.1时期用的,在.NET Framework 2.0中,新增了ConnectionStrings. 1.<connectionStrings> &l ...

  9. AppSettings

    1.winform中读写配置文件appSettings 一节中的配置. #region 读写配置文件 /// <summary> /// 修改配置文件中某项的值 /// </summ ...

随机推荐

  1. 洛谷 P1182 数列分段`Section II`【二分答案】

    [代码]: #include<bits/stdc++.h> const double eps = 1e-8; const int maxn = 1e6+5; #define inf 0x3 ...

  2. 2017中国大学生程序设计竞赛 - 女生专场A【模拟】

    A HDU - 6023 [题意]:求AC题数和总时长. [分析]:模拟.设置标记数组记录AC与否,再设置错题数组记录错的次数.罚时罚在该题上,该题没AC则不计入总时间,AC则计入.已经AC的题不用再 ...

  3. HDU 2552 三足鼎立(数学函数)

    /* <耶律javac++>欲找出三人所在逐个击破, 现在他发现威士忌的位置s,天外来客的位置u, 不过很难探查到亦纷菲v所在何处,只能知道三人满足关系: arctan(1/s) = ar ...

  4. [xsy2363]树

    设$f_{i,j}$表示$i$个点的树,权值为$j$且可以不选根的方案数,$g_{i,j}$表示$i$个点的树,权值为$j$且必选根的方案数 首先$g_{1,1}=0$ 我们可以把原树连上一个新的子树 ...

  5. CSS3:绘制图形

    CSS画图形,基本上所有的实现都是对边框的角度的调整及组合. 以下不包含兼容浏览器的前缀,请使用时在border-radius前加-moz-.-webkit- .... 1.正常得不得了的矩形 .sq ...

  6. DOM系统学习-进阶

    DOM类型  Node类型: 常用类型: ​    ​    ​元素节点 ELEMENT_NODE ​    ​    ​属性节点 ATTRIBUTE_NODE ​    ​    ​文本节点 TEX ...

  7. [Git] Git 的origin和master分析

    转载: http://lishicongli.blog.163.com/blog/static/1468259020132125247302/ 首先要明确一点,对git的操作是围绕3个大的步骤来展开的 ...

  8. ubuntu登录黑屏“failed to start session”, gdm+kdm+lightdm

    sudo apt-get install ubuntu-desktop sudo systemctl start gdm sudo service lightdm restart sudo syste ...

  9. The method Inflate() in android

    Inflate() method can find out a layout defined by xml,as like the findViewById() method,but there ha ...

  10. Centos6.5搭建RHCS集群-实现GFS+iSCSI网络共享存储

    RHCS集群配置 需要用到的各组件功能:RHCS(Red Hat Cluster Suite):能够提供高可用性.高可靠性.负载均衡.存储共享且经济廉价的集群工具集合.LUCI:是一个基于web的集群 ...