2010-08-08 43 views

回答

0

當然可以,Web配置是XML文檔,因此您可以像XML文檔一樣訪問它們。
oXMLDoc將是您的Web配置文件,可以通過System.Web.HttpContext.Current.Server.MapPath(「web.config」)解壓縮。或((Assembly.GetEntryAssembly())。GetName())。Name +「.exe.config」

private String GetNodeValue(ref XmlDocument oXMLDoc, String sPath) 
{ 
    String sValue = ""; 
    XmlNode oNode = oXMLDoc.SelectSingleNode(sPath); 
    if (oNode != null) 
    { 
     sValue = oNode.InnerText.Trim(); 
    } 
    return sValue; 
} 

private void SetNodeValue(ref XmlDocument oXMLDoc, String sPath, String sValue) 
{ 
    XmlNode oNode = oXMLDoc.SelectSingleNode(sPath); 
    if (oNode != null) 
    { 
     oNode.InnerText = sValue; 
    } 
}