ConfigurationManager.AppSettings 属性 appSettings
2024-08-25 12:40:36
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>
最新文章
- 从零开始,DIY一个jQuery(1)
- 学习 opencv---(8)非线性滤波:中值滤波,双边滤波
- codeforces 742E (二分图着色)
- spirng线程池的配置与使用
- 第37讲:List的foldLeft、foldRight、sort操作代码实战
- 详解Winform里面的缓存使用
- web负载均衡
- 【gradle报错】error: package org.apache.http does not exist
- Android开发学习之Intent具体解释
- 找呀志_ContentResolver操作ContentProvider数据
- subversion-fundamental concepts
- Linux学习——Shell基础
- loadView
- SpringBoot HttpServletResponse Header Cookie输出问题
- 算法手记(2)Dijkstra双栈算术表达式求值算法
- 2553 ACM N皇后 回溯递归
- Navicat连接MySQL8.0亲测有效
- centos 安装thrift
- ISO7816之管脚定义
- Python 数值计算库之-[Pandas](六)
热门文章
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals )D. Innokenty and a Football League(2-sat)
- POJ1861 Network(Kruskal)(并查集)
- 中文名: 交通事故责任认定, 英文名称: Traffic accident responsibility identification
- java中的3大特性之多态
- luogu P3368 【模板】树状数组 2
- [BZOJ2655]calc(拉格朗日插值法+DP)
- spring boot 2.x静态资源会被HandlerInterceptor拦截的原因和解决方法
- 在WPF中合并两个ObservableCollection
- delphi设计浮动窗口
- Zookeeper api增删改查节点