- 热门文章:
- · 完整的在.net后台执行javascript脚本集合
- · .net手机软件开发(六)OBEX应用——文件传输部分
- · .net手机软件开发(5)——OBEX介绍
- · .NET Framework General Reference - Capitalization Styles
- · Framework 类库的事件编程
- · .net下模拟不同身份登陆以获取不同权限
- · .Net 缓存代理类 的初步考虑.
- · 把.NET程序部署到没有安装.NET Framwork的机器上
- · .NET Remoting编程简介
- · 基于.Net Framework的N层分布式应用开发
- · 使用.NET实现视频播放
- · 基于.Net Framework的N层分布式应用开发
上一篇:深入理解.NET 的JIT编译方式 >>
.Net配置文件常用配置说明
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="mySection" type="System.Configuration.NameValueSectionHandler"/>
<section name="mySingleTagSection" type="System.Configuration.SingleTagSectionHandler"/>
<section name="myDictionarySection" type="System.Configuration.DictionarySectionHandler"/>
<sectionGroup name="mySections">
<section name="mySection1" type="System.Configuration.NameValueSectionHandler"/>
<section name="mySection2" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<mySection>
<add key="key1" value="value1" />
<add key="key2" value="value2" />
</mySection>
<mySingleTagSection setting1="value1" setting2="value2" setting3="value3" />
<myDictionarySection>
<add key="DictionarySectionKey1" value="DictionarySectionValue1"/>
<add key="DictionarySectionKey2" value="DictionarySectionValue2"/>
<add key="DictionarySectionKey3" value="DictionarySectionValue3"/>
</myDictionarySection>
<mySections>
<mySection1>
<add key="mySection1_key1" value="mySection1_value1" />
<add key="mySection1_key2" value="mySection1_value2" />
</mySection1>
<mySection2>
<add key="mySection2_key1" value="mySection2_value1" />
<add key="mySection2_key2" value="mySection2_value2" />
</mySection2>
</mySections>
<appSettings>
<add key="appkey1" value="appvalue1" />
<add key="appkey2" value="appvalue2" />
</appSettings>
</configuration>
代码片断如下:
private static void TestAppSettings()
{
Console.WriteLine("TestAppSettings ...");
NameValueCollection config = ConfigurationSettings.AppSettings;
Console.WriteLine("value1:" + config["key1"]);
Console.WriteLine("value2:" + config["key2"]);
Console.WriteLine();
}
private static void TestSection()
{
Console.WriteLine("TestSection ...");
NameValueCollection config ;
config = (NameValueCollection)ConfigurationSettings.GetConfig("mySection");
Console.WriteLine("value1:" + config["key1"]);
Console.WriteLine("value2:" + config["key2"]);
Console.WriteLine();
}
private static void TestSingleTagSection()
{
Console.WriteLine("TestSingleTagSection ...");
IDictionary dic ;
dic = (IDictionary)ConfigurationSettings.GetConfig("mySingleTagSection");
Console.WriteLine("value1:" + dic["setting1"]);
Console.WriteLine("value2:" + dic["setting2"]);
Console.WriteLine("value3:" + dic["setting3"]);
Console.WriteLine();
}
private static void TestDictionarySection()
{
Console.WriteLine("TestDictionarySection ...");
IDictionary dic ;
dic = (IDictionary)ConfigurationSettings.GetConfig("myDictionarySection");
Console.WriteLine("DictionarySectionValue1:" + dic["DictionarySectionKey1"]);
Console.WriteLine("DictionarySectionValue2:" + dic["DictionarySectionKey2"]);
Console.WriteLine("DictionarySectionValue3:" + dic["DictionarySectionKey3"]);
Console.WriteLine();
}
private static void TestSectionGroup()
{
Console.WriteLine("TestSectionGroup ...");
NameValueCollection config1 ;
NameValueCollection config2 ;
config1 = (NameValueCollection)ConfigurationSettings.GetConfig("mySections/mySection1");
config2 = (NameValueCollection)ConfigurationSettings.GetConfig("mySections/mySection2");
Console.WriteLine("mySections/mySections1/value1:" + config1["mySection1_key1"]);
Console.WriteLine("mySections/mySections1/value2:" + config1["mySection1_key2"]);
Console.WriteLine("mySections/mySections2/value1:" + config2["mySection2_key1"]);
Console.WriteLine("mySections/mySections2/value2:" + config2["mySection2_key2"]);
Console.WriteLine();
}
下一篇:完整的在.net后台执行javascript脚本集合 >>
相关文章:
- · .NET 程序,调用其它程序
- · 在.net开发中几个重要的认识误区(1)
- · 关于.net下服务安装
- · .NET的自动序列号工具
- · ADO.NET学习笔记(一)
- · .Net配置log4net
- · 一个经典的ADO.NET入门例子
- · 在.net使用代理浏览网页
- · .net 有关多态性的学习笔记。
- · 在.net中读写INI文件
- · 学习笔记《.NET框架程序设计(修订版)》--第三章 共享程序集 (3)
- · MyCollege.Net系统规划与总体设计
- · 学习笔记《.NET框架程序设计(修订版)》--第三章 共享程序集 (2)
- · Metadata and Reflection in .NET
- · 在.net执行sql脚本的简单实现
- · .Net下WebMethod属性
- · .NET客户端应用程序:.NET应用程序更新组件(6)
- · .NET客户端应用程序:.NET应用程序更新组件(5)
- · 创建分布式应用程序学习心得
- · 基于组件的.NET软件开发(1)
- · .net关于企业Excel报表的生成
- · 使用 Visual C# .NET 在 ADO.NET 中以编程方式构建连接字符串
- · 让用户通过宏和插件向您的 .NET 应用程序添加功能
- · Visual Basic.NET和GDI+共创图标编辑器
- · Visual Basic .NET 中动态加载类 (三)
- · Visual Basic .NET 中动态加载类 (二)
- · Visual Basic .NET 中动态加载类(一)
- · 我的.Net下应用程序发布问题的简易解决方案
- · 关于自定义事件的一点体会
- · .net 中的事务总结
- · .net中一些所封装的类
- · .Net 下对SqlServer2000中的存储过程的调用
- · .Net 下对SqlServer2000中的存储过程的调用
- · .NET组件和COM组件之间的相互操作
- · 权限管理工具的使用方法
- · .net关于企业Excel报表的生成
- · .NET Test Driven Development
- · 使用 Visual C# .NET 向 Microsoft Excel 2002 传输 XML 数据
