最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.net 讀取非標準配置文件的小例子

 更新時間:2013年07月30日 10:22:01   作者:  
這篇文章介紹了.net 讀取非標準配置文件的小例子,有需要的朋友可以參考一下
代碼如下:
復(fù)制代碼 代碼如下:

public static string Config(string key) 
       { 
           ExeConfigurationFileMap file = new ExeConfigurationFileMap(); 
           file.ExeConfigFilename = @"Providers\\Provider.config"; 
           Configuration config = ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None); 
           AppSettingsSection appsection = (AppSettingsSection)config.GetSection("appSettings"); 
           return appsection.Settings[key].Value; 
       } 

配置文件目錄結(jié)構(gòu):
復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
        <add key="ConnectionString" value="Server=(local);Database=DB;User Id=sa;Password=123" /> 
    </appSettings> 
</configuration> 

調(diào)用:
復(fù)制代碼 代碼如下:

//里面的參數(shù)為配置文件的key  
string strConn=Config("ConnectionString"); 

相關(guān)文章

最新評論

礼泉县| 东辽县| 毕节市| 香港 | 开封县| 昭觉县| 时尚| 台湾省| 怀化市| 呼图壁县| 沙洋县| 历史| 宜兴市| 盐津县| 临夏市| 黑龙江省| 汤阴县| 漯河市| 桂东县| 旬阳县| 河间市| 香格里拉县| 铜川市| 棋牌| 五家渠市| 高清| 桂东县| 芜湖县| 伊宁县| 吉水县| 大同市| 错那县| 土默特左旗| 左权县| 兴宁市| 固原市| 庆元县| 凤阳县| 呈贡县| 榆林市| 云南省|