Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  Asp.net  >  正文 C# 读取配置文件(指定路径)的方法

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

发布时间:2015-12-20   编辑:www.jquerycn.cn
用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的方法
有关c#操作目录-文件-字符串的类
file.getPath() getAbsolutePath() getCanonicalPath()区别
构建可配置PHP应用程序的正确方式
jquery.cookie() 方法的使用(读取、写入、删除)
Mac 下使用 clion 调试 PHP 内核源码
ASP FileSystem 对象
asp.net C#获取DLL、程序路径,C#获取桌面、收藏夹等特殊系统路径
C# Winform中获取文件路径的方法

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