zoukankan      html  css  js  c++  java
  • 使用自定义的config

    string configPath = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath.ToString(), "WebAddress.config");//配置文件的地址
                ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(configPath);
                configMap.ExeConfigFilename = configPath;
                Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
                var section = (AppSettingsSection)config.GetSection("ipAddress"); //获取config section
                string results = section.Settings[key].Value;
                return results;

    附 WebAddress.config文件:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <section name="ipAddress" type="System.Configuration.AppSettingsSection" />
      </configSections>
     
      <ipAddress>
        <add key="adminTarget" value="202.127.207.182:9999"></add>
        <add key="adminPres" value="202.127.207.184:7001"></add>
        <add key="knowledge" value="202.127.207.182:8097"></add>
        <add key="synReport" value="202.127.207.182:8888"></add>
      </ipAddress>

    </configuration>

    注:namevalue 类型 在自定义的config文件中不可用

  • 相关阅读:
    oracle数据库基础知识汇总—30天(一)
    SQL server
    mySQL 黑窗口运行命令
    MySQL
    常用网址
    常见浏览器JS引擎和内核
    nodejs
    audio标签自动播放在安卓播放正常,IOS不能自动播放
    Microsoft.Office.Interop.Excel Find 操作
    python 的os.getenv("PATH")和os.environ.get("PATH")的区别
  • 原文地址:https://www.cnblogs.com/wangjiachen/p/4350333.html
Copyright © 2011-2022 走看看