亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

.net 讀取非標(biāo)準(zhǔn)配置文件的小例子

 更新時(shí)間:2013年07月30日 10:22:01   作者:  
這篇文章介紹了.net 讀取非標(biāo)準(zhǔn)配置文件的小例子,有需要的朋友可以參考一下
代碼如下:
復(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)文章

最新評論