Asp.net 读取config文件

config:

<?xml version="1.0"?>
<appSettings>
  <!-- The path about dbConnectionString -->
  <add key="DBConnectionStringFile" value="D:\C3\config\Microsoft.Msn.Tokyo.DbConnectionString.xml"></add>
  
  <!-- The key to get c3ArticleDBConnectionString from dbConnectionstring -->
  <add key="ConnectionStringKey" value="SearchConnectionString"></add>
  
  </appSettings>


读取:

  

string dbXmlFileName = this.xmlDBConnectionStringFile;
            XmlDocument xmlD = new XmlDocument();
            xmlD.Load(dbXmlFileName);
            this.strSqlConn = xmlD.SelectSingleNode("/DBConnectionString/" + this.xmlConnectionStringKey).Attributes["value"].Value;
原文地址:https://www.cnblogs.com/2814/p/2773120.html