configurationmanager.getsection usage
public static void CreateAppSettings()
{
// Get the application configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None); string sectionName = "appSettings"; // Add an entry to appSettings.
int appStgCnt =
ConfigurationManager.AppSettings.Count;
string newKey = "NewKey" + appStgCnt.ToString(); string newValue = DateTime.Now.ToLongDateString() +
" " + DateTime.Now.ToLongTimeString(); config.AppSettings.Settings.Add(newKey, newValue); // Save the configuration file.
config.Save(ConfigurationSaveMode.Modified); // Force a reload of the changed section. This
// makes the new values available for reading.
ConfigurationManager.RefreshSection(sectionName); // Get the AppSettings section.
AppSettingsSection appSettingSection =
(AppSettingsSection)config.GetSection(sectionName); Console.WriteLine();
Console.WriteLine("Using GetSection(string).");
Console.WriteLine("AppSettings section:");
Console.WriteLine(
appSettingSection.SectionInformation.GetRawXml());
}
configurationmanager.getsection usage的更多相关文章
- configurationmanager.getsection usage example.
1.app.config(note that attribute case sensitive!) <?xml version="1.0" encoding="ut ...
- ConfigurationManager.GetSection()方法的使用
GetSection方法读取的是configSections节点,这个节点在web.config配置文件中,它比较特殊,必须放置于首节点,也就是说,在它之前不能有其它类型的节点.configSecti ...
- ASP.NET 系列:单元测试之ConfigurationManager
通过ConfigurationManager使用.NET配置文件时,可以通过添加配置文件进行单元测试,虽然可以通过测试但达不到解耦的目的.使用IConfigurationManager和Configu ...
- System.ConfigurationManager类用于对配置文件的读取
http://blog.csdn.net/ligenyingsr/article/details/54095986 System.ConfigurationManager类用于对配置文件的读取.其具有 ...
- .NetCore技术研究-ConfigurationManager在单元测试下的坑
最近在将原有代码迁移.NET Core, 代码的迁移基本很快,当然也遇到了不少坑,重构了不少,后续逐步总结分享给大家.今天总结分享一下ConfigurationManager遇到的一个问题. 先说一下 ...
- MongoDb 配置笔记
安装: 官网:https://www.mongodb.org/ 按官方教程: http://docs.mongodb.org/master/tutorial/install-mongodb-on-re ...
- Akka.net路径里的user
因为经常买双色球,嫌每次对彩票号麻烦,于是休息的时候做了个双色球兑奖的小程序,做完了发现业务还挺复杂的,于是改DDD重做设计,拆分服务,各种折腾...,不过这和本随笔没多大关系,等差不多了再总结一下, ...
- 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...
- WCF基础
初入职场,开始接触C#,开始接触WCF,那么从头开始学习吧,边学边补充. SOA Service-Oriented Architecture,面向服务架构,粗粒度.开放式.松耦合的服务结构,将应用程序 ...
随机推荐
- ARM协处理器
协处理器是一种芯片,用于减轻系统微处理器的特定处理任务.例如,数学协处理器可以控制数字处理:图形协处理器可以处理视频绘制.例如,intel pentium微处理器就包括内置的数学协处理器. 协处理器 ...
- 通过sudo提权方式控制公司人员权限
#通过visudo编辑/etc/sudoers Runas_Alias OP = root #定义使用sudo的时候以哪个用户执行命令,一般都是使用root #命令别名 Cmnd_Alias NETW ...
- LNMP源码安装脚本
LNMP安装脚本,脚本环境 #LNMP环境搭建centos6.8 2.6.32-696.28.1.el6.x86_64 nginx:1.12.2 mysql:5.6.36 PHP:5.5. ...
- 09.VUE学习之watch监听属性变化实现类百度搜索栏功能ajax异步请求数据,返回字符串
cmd下安装axios npm install axios 安装好后,会多出node_modules文件夹 思路: 监听data里的word改变时,发送ajax异步请求数据, 把返回的数据赋值给dat ...
- codeforces 258D DP
D. Little Elephant and Broken Sorting time limit per test 2 seconds memory limit per test 256 megaby ...
- Linux命令之---cat
命令简介 cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 命令格式 cat [选项] [文 ...
- 使用Vue CLI3开发多页面应用
一.安装vue-cli3 1.如果你已经全局安装了旧版本的 vue-cli(1.x 或 2.x),你需要先通过 npm uninstall vue-cli -g 或 yarn global remov ...
- 59、佳博wifi打印机怎么配置
1.去这里下载配置软件(注意,需要再windows下进行)http://pan.baidu.com/s/1bn1y4FX,并解压安装程序 2.连上wifi打印机的热点,比如说佳博打印机的默认为Gpri ...
- ogre3D学习基础17 --- 如何手动创建ogre程序
建立自己的Ogre程序 一直以来都是使用ExampleApplication.h来写程序,现在来看看它到底有什么神奇的地方. 首先,我们新建一个win32空项目 然后配置环境 最后新建define.c ...
- Python+Selenium基础篇之2-打开和关闭火狐浏览器
本节介绍如何初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打开fiefox浏览器.首先需要去下载一个driver插件geckodriver. ...