<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 ]的更多相关文章

  1. [转]WinForm和WebForm下读取app.config web.config 中邮件配置的方法

    本文转自:http://blog.csdn.net/jinbinhan/article/details/1598386 1. 在WinForm下读取 App.config中的邮件配置语句如下: Con ...

  2. C#Unit单元测试之读取Web.config文件

    长期一来,我们所完成的项目都没有写单元测试,今天我一时兴起,决定给自己写的代码写单元测试,简单的测试代码分分钟完成了,一运行测试,就懵逼了.没能达到我的预期效果,而是出现图1所示错误. 图1:单元测试 ...

  3. asp.net 2.0中新增的web.config的默认namespace功能 (转)

    看上去这个题目比较长,但实际上,我在看资料时发现,这就是说,在asp.net 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用 ...

  4. MVC.Net:读取Web.config/App.config配置

    需要读取Web.config/App.config的配置很简单,首先我们需要将配置写入到<appSettings>中,例如: <appSettings> <add key ...

  5. C#读取web.config配置文件内容

    1.对配置文件的访问. 方法一: string myConn =System.Configuration.ConfigurationManager.ConnectionStrings["sq ...

  6. 如何高逼格读取Web.config中的AppSettings

    http://edi.wang/post/2015/4/22/how-to-read-webconfig-appsettings-with-bigiblity 先插句题外话,下版本的ASP.NET貌似 ...

  7. 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 ...

  8. c# 如何读取web.config中的内容(ConfigurationManager)

    1.web.config中写入 <appSettings>    <add key="TokenQPark" value="http://localho ...

  9. 读取、添加、删除、修改配置文件 如(Web.config, App.config)

    private Configuration config; public OperateConfig() : this(HttpContext.Current.Request.ApplicationP ...

随机推荐

  1. 11997 - K Smallest Sums(优先队列)

    11997 - K Smallest Sums You’re given k arrays, each array has k integers. There are kk ways to pick ...

  2. js获取控件位置

    //获取坐标位置 function getpos(e) { var t=e.offsetTop; var l=e.offsetLeft; var height=e.offsetHeight; whil ...

  3. stm32之Systick(系统时钟)

    Systick的两大作用: 1.可以产生精确延时: 2.可以提供给操作系统一个单独的心跳(时钟)节拍: 通常实现Delay(N)函数的方法为: for(i=0;i<x;i++) ; 对于STM3 ...

  4. [Swust OJ 541]--排列字典序问题

    题目链接:http://acm.swust.edu.cn/problem/0541/ Time limit(ms): 2000 Memory limit(kb): 65535 n个元素{1,2,... ...

  5. iOS- 三步快速集成社交化分享工具ShareSDK

    http://www.cnblogs.com/qingche/p/3727559.html 1.前言 作为现在App里必不可少的用户分享需要,社交化分享显然是我们开发app里较为常用的. 最近因为公司 ...

  6. dotnet tools 运行 dotnet run

    dotnet tools 运行 dotnet run dotnet run 命令介绍 前言 本篇主要介绍 asp.net core 中,使用 dotnet tools 运行 dotnet run 之后 ...

  7. shu_1548 悟空问题(大哥,主妖怪抓走的朋友!)

    http://202.121.199.212/JudgeOnline/problem.php?cid=1078&pid=17 分析:  直接暴力了.. . 代码: #include <s ...

  8. PrintDocument组件打印

    运行效果: 代码: using System; using System.Collections.Generic; using System.ComponentModel; using System. ...

  9. word2013 无endnote选项卡咋办

    word2013 无endnote选项卡咋办? 前提: 已经安装了endnotex7,office word2013 word->文件->选项->加载项->最下面的 管理 &q ...

  10. Qt 释放新建窗口资源

    当Widget *w = new Widget(); 不方便调用 delete w;时 Widget *w = new Widget(); w->setAttribute(Qt::WA_Dele ...