ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]
<configuration>
<appSettings>
<add key="name" value="HF_Ultrastrong"/>
</appSettings>
<connectionStrings>
<add name="ConString" connectionString="server = ***; DATABASE = DB_News; integrated security = true"/>
</connectionStrings>
</configuration>
获取配置文件中<appSettings>或是<connectionStrings>的值:
<appSettings>:
//方法1
string Name = ConfigurationManager.AppSettings["name"].ToString();
//方法2
string Name = ConfigurationManager.AppSettings["name"];
<connectionStrings>:
string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]的更多相关文章
- [转]WinForm和WebForm下读取app.config web.config 中邮件配置的方法
本文转自:http://blog.csdn.net/jinbinhan/article/details/1598386 1. 在WinForm下读取 App.config中的邮件配置语句如下: Con ...
- C#Unit单元测试之读取Web.config文件
长期一来,我们所完成的项目都没有写单元测试,今天我一时兴起,决定给自己写的代码写单元测试,简单的测试代码分分钟完成了,一运行测试,就懵逼了.没能达到我的预期效果,而是出现图1所示错误. 图1:单元测试 ...
- asp.net 2.0中新增的web.config的默认namespace功能 (转)
看上去这个题目比较长,但实际上,我在看资料时发现,这就是说,在asp.net 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用 ...
- MVC.Net:读取Web.config/App.config配置
需要读取Web.config/App.config的配置很简单,首先我们需要将配置写入到<appSettings>中,例如: <appSettings> <add key ...
- C#读取web.config配置文件内容
1.对配置文件的访问. 方法一: string myConn =System.Configuration.ConfigurationManager.ConnectionStrings["sq ...
- 如何高逼格读取Web.config中的AppSettings
http://edi.wang/post/2015/4/22/how-to-read-webconfig-appsettings-with-bigiblity 先插句题外话,下版本的ASP.NET貌似 ...
- asp.net设置默认打开页面,Web.config,defaultDocument
The web.config file can be used to set a default document, or list of default documents for your web ...
- c# 如何读取web.config中的内容(ConfigurationManager)
1.web.config中写入 <appSettings> <add key="TokenQPark" value="http://localho ...
- 读取、添加、删除、修改配置文件 如(Web.config, App.config)
private Configuration config; public OperateConfig() : this(HttpContext.Current.Request.ApplicationP ...
随机推荐
- vc 获取网页内容(HTTP)
BOOL bResult = FALSE; // 初始化WinInet 环境 HINTERNET hInternet = InternetOpen("CEHTTP", ...
- Battle ships(二分图,建图,好题)
Battle ships Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- iOS中的图像处理(一)——基础滤镜
最近在稍微做一些整理,翻起这部分的代码,发现是两个多月前的了. 这里讨论的是基于RGBA模型下的图像处理,即将变换作用在每个像素上. 代码是以UIImage的category形式存在的: typede ...
- iOS 文件操作:沙盒(SandBox)、文件操作(FileManager)、程序包(NSBundle)
版权声明:本文为博主原创文章,转载请声明出处:http://blog.csdn.net/jinnchang 1.沙盒机制介绍 iOS 中的沙盒机制(SandBox)是一种安全体系.每个 iOS 应用程 ...
- F - Free DIY Tour(动态规划,搜索也行)
这道题可用动态规划也可以用搜索,下面都写一下 Description Weiwei is a software engineer of ShiningSoft. He has just excelle ...
- 再见了acm
2013年11月17日长沙区域赛我的最后一场区域赛. 忙碌了三年的acm要停下脚步,一时还无法接受. 这样一个结果有点无奈. 感谢队友,三年三支队伍五个队友,感谢你们.(每当写到这里时就总有点小忍不住 ...
- Spring Boot 探索系列 - 自动化配置篇
26. Logging Prev Part IV. Spring Boot features Next 26. Logging Spring Boot uses Commons Logging f ...
- VC中关于 0xcccccccc和 0xcdcdcdcd异常
VC在调试时,可能会报“写入位置0xcccccccc 时发生访问冲突”,或者“写入位置0xcdcdcdcd 时发生访问冲突”,这些问题可能是由于使用了未初始化的指针引起的. 在 Debug 模式下,V ...
- 给刚通过51入门的新人讲讲S12(MCS12XS128)与51的差别
MCS51是keil也对应地做好了非常多,也就是有非常多对你而言是透明的,是你不必关心的,你所要接触的寄存器数量也非常小,在这个时候你很多其它是写函数,仅仅只是针对这个平台写C程序比在PC上写C控制台 ...
- 将EC2里的实例导出到RAW文件并进行修改
你可能有自己的instance在amazon云环境里面,或者是你想深度修改一下marketplace里面提供的那些系统又估计运行中的instance改动不方便 亚马逊作为云计算领域的大哥大,我不得不说 ...