您现在的位置是:首页 >

读取配置文件失败是什么意思 .net 读取非标准配置文件的小例子

火烧 2021-07-23 03:22:32 1043
. et 读取非标准配置文件的小例子 这篇文章介绍了 et 读取非标准配置文件的小例子 有需要的朋友可以参考一下   代码如下复制代码 代码如下: u lic tatic tri g Co fig t

.net 读取非标准配置文件的小例子  

这篇文章介绍了 net 读取非标准配置文件的小例子 有需要的朋友可以参考一下  

  代码如下

复制代码 代码如下: public static string Config(string key)         {             ExeConfigurationFileMap file = new ExeConfigurationFileMap();             file ExeConfigFilename = @"ProvidersProvider config";             Configuration config = ConfigurationManager OpenMappedExeConfiguration(file ConfigurationUserLevel None);             AppSettingsSection appsection = (AppSettingsSection)config GetSection("appSettings");             return appsection Settings[key] Value;         } 

   配置文件目录结构

读取配置文件失败是什么意思 .net 读取非标准配置文件的小例子
复制代码 代码如下: <?xml version=" " encoding="utf " ?>  <configuration>      <appSettings>          <add key="ConnectionString" value="Server=(local);Database=DB;User Id=sa;Password= " />      </appSettings>  </configuration> 

   调用

复制代码 代码如下: lishixinzhi/Article/program/net/201311/14052  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码