2010-08-08 6 views

Répondre

0

Bien sûr que vous le pouvez, les Web Configs sont des documents XML, vous pouvez donc y accéder comme des documents XML.
oXMLDoc sera votre fichier Web Config qui peut être extrait par System.Web.HttpContext.Current.Server.MapPath ("web.config"); ou ((Assembly.GetEntryAssembly()). GetName()). Nom + ".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; 
    } 
} 
Questions connexes