ConfigurationManager.AppSettings 属性 appSettings
https://msdn.microsoft.com/zh-cn/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx
ConfigurationManager.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的更多相关文章
- c#修改config中的AppSettings属性
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfa.AppS ...
- ConfigurationManager.ConnectionStrings 属性
public static ConnectionStringSettingsCollection ConnectionStrings { get; } App.config <?xml vers ...
- ConfigurationManager.AppSettings方法
一 配置文件概述: 应用程序配置文件是标准的 XML 文件,XML 标记和属性是区分大小写的.它是可以按需要更改的,开发人员可以使用配置文件来更改设置,而不必重编译应用程序.配置文件的根节点是conf ...
- ConfigurationManager 读写AppSettings键值对
using System; using System.Configuration; namespace ConsoleApplication1 { class Program { static voi ...
- ConfigurationManager.AppSettings Property
在app.config文件中添加如下配置 <appSettings> <add key="Server" value="127.0.0.1"/ ...
- AppSettings和connectionStrings的却别(转)
AppSettings是ASP.NET1.1时期用的,在.NET Framework 2.0中,新增了ConnectionStrings. 1.<connectionStrings> &l ...
- <connectionStrings> <appSettings> 读取方法
C#中ConnectionStrings和AppSettings的区别 时间 2013-03-07 15:57:00 博客园精华区 原文 http://www.cnblogs.com/bindot ...
- [转载]AppSettings和ConnectionStrings的区别
AppSettings是ASP.NET1.1时期用的,在.NET Framework 2.0中,新增了ConnectionStrings. 1.<connectionStrings> &l ...
- AppSettings
1.winform中读写配置文件appSettings 一节中的配置. #region 读写配置文件 /// <summary> /// 修改配置文件中某项的值 /// </summ ...
随机推荐
- 简单DP【p2642】双子序列最大和
Description 给定一个长度为n的整数序列,要求从中选出两个连续子序列,使得这两个连续子序列的序列和之和最大,最终只需输出最大和.一个连续子序列的和为该子序列中所有数之和.每个连续子序列的最小 ...
- oracle tablespace usage status
select a.tablespace_name, a.bytes / 1024 / 1024 "Sum MB", (a.bytes - b.bytes) / 1024 / 102 ...
- 对mysql 数据库操作 使其支持插入中文(针对python)
首先,这项任务确切的说需要三步吧: #1.建立数据库(数据库名为xsk) create database `xsk` character set 'utf8' collate 'utf8_genera ...
- [BZOJ 2809] Dispatching
Link:https://www.lydsy.com/JudgeOnline/problem.php?id=2809 Algorithm: 很容易看出此题贪心的思路: 只要在每个点的子树中贪心选取费用 ...
- 【后缀数组】【二分答案】poj3261
注意:对整型数组求sa时,s[n]请置成-1. 请离散化. 可重叠的 k 次最长重复子串(pku3261)给定一个字符串,求至少出现 k 次的最长重复子串,这 k 个子串可以重叠.算法分析:先二分答案 ...
- SqlMapConfig.xml详细介绍
1,连接数据库 <!--配置环境,默认的环境id为oracle --> <environments default="oracle"> <!-- 配置 ...
- iOS开发——给ImageView添加点击事件
给ImageView添加点击事件 1: cell.pictureView.userInteractionEnabled = YES; 2: UITapGestureRecognizer ...
- 虚拟内存,MMU/TLB,PAGE,Cache之间关系
转:http://hi.baidu.com/gilbertjuly/item/6690ba0dfdf57adfdde5b040 虚拟地址VA到物理地址PA以页page为单位.通常page的大小为4K. ...
- insert语句太长,有StringBuilder优化一下
private void btnSave_Click(object sender, RoutedEventArgs e) { if (IsInsert) { //假设日历控件没有选日期,那帮它赋一个当 ...
- ASP.NET MVC file download sample
ylbtech- ASP.NET MVC:ASP.NET MVC file download sample 功能描述:ASP.NET MVC file download sample 2,Techno ...