教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 C# 读取配置文件(指定路径)的方法

C# 读取配置文件(指定路径)的方法

发布时间:2015-12-20   编辑:jiaochengji.com
用c#读取指定路径的配置文件,这里为大家提供一段参考代码,有需要的朋友,可以看看。

c#读取配置文件。

复制代码 代码示例:

ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = @"E:\site.config"; ;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
string connstr = config.ConnectionStrings.ConnectionStrings["connStr"].ConnectionString;
MessageBox.Show(connstr);
string key = config.AppSettings.Settings["key"].Value;
MessageBox.Show(key);

您可能感兴趣的文章:
C# 读取配置文件(指定路径)的方法
python使用pandas处理excel的方法
Go语言从入门到精通 -【web项目实战篇】- 读取配置文件
有关c#操作目录-文件-字符串的类
file.getPath() getAbsolutePath() getCanonicalPath()区别
jquery.cookie() 方法的使用(读取、写入、删除)
构建可配置PHP应用程序的正确方式
Mac 下使用 clion 调试 PHP 内核源码
asp.net C#获取DLL、程序路径,C#获取桌面、收藏夹等特殊系统路径
jquery.cookie用法详细解析

关键词: 读取配置文件   
[关闭]
~ ~