Link to home
Start Free TrialLog in
Avatar of ttnetworks
ttnetworks

asked on

Edit the Default IIS Website Path

Hi,

As part of an application I am developing, I need to change the path of the Default IIS website when the software is installed.

This appeared to be quite easy after some searching, but the code I have is returning an "Unknown Error"

Code:

            public static void Configure()
            {
                  DirectoryEntry objDEParent = new DirectoryEntry(@"IIS://localhost/LM/W3SVC/1/ROOT/");

                  objDEParent.Properties["Path"][0] = @"C:\Web";

                  objDEParent.CommitChanges();
            }
Error:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_AdsObject()
   at System.DirectoryServices.PropertyValueCollection.PopulateList()
   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
   at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)

All I need to to do is change the Document path for the default IIS website so it points to the folder our software is installed in.

Thanks

Andrew
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ttnetworks
ttnetworks

ASKER

Hi,

Nope. Reports the same error.

This is on a Windows XP Pro SP2 Machine, which uses IIS 5.1 ?

Thanks

Andrew
I'm surprised you're still getting the error while I'm able to run the code on the same XP Pro with SP2 and of course IIS 5.1 without any problem.

Just for testing, can you run this code?

DirectoryEntry de = new DirectoryEntry(@"IIS://localhost/W3svc/1/Root");
Console.WriteLine(de.Properties["Path"].Value);
foreach ( String s in de.Properties.PropertyNames )
{
      Console.WriteLine(s);
}
Hi,

Yep that code runs OK.

Andrew
Hi,

All working now, those / make a big difference :-)

Thanks for the help.

Andrew