-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
Kerry Whelan
Sent: Friday, May 17, 2002 4:12 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Accessing and editing the web.config file


> This worked well, thankyou. Do you know how I can access and edit the
> settings in system.web section?

Just change the XPath statement to the node in question.

        XmlDocument doc = New XmlDocument();
        doc.load(Server.Mappath("web.config"));
        XmlAttribute userPass =
(XmlAttribute)doc.SelectSingleNode("configuration/system.web/authentication/
credentials/user[@name='Bob']/@password");
        userPass.NodeValue = "imbatman";

Note also that each directory can have its own web.config file, so if you
want to edit the web.config in the parent directory, change the parameter
for Server.Mappath to use a relative directory path.

Kirk Allen Evans
"XML and ASP.NET", New Riders Publishing
Available at Amazon.com
http://www.amazon.com/exec/obidos/ASIN/073571200X

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to