章术

导航

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;

 

posted on 2012-11-16 13:38  章术  阅读(298)  评论(0编辑  收藏  举报