?
Solved

Edit the Default IIS Website Path

Posted on 2005-03-21
5
Medium Priority
?
914 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:ttnetworks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
ihenry earned 2000 total points
ID: 13591855
Try this

               DirectoryEntry objDEParent = new DirectoryEntry(@"IIS://localhost/W3svc/1/Root");
               objDEParent.Properties["Path"].Value = @"C:\Web";
               objDEParent.CommitChanges();
0
 

Author Comment

by:ttnetworks
ID: 13593776
Hi,

Nope. Reports the same error.

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

Thanks

Andrew
0
 
LVL 20

Expert Comment

by:ihenry
ID: 13601325
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);
}
0
 

Author Comment

by:ttnetworks
ID: 13604100
Hi,

Yep that code runs OK.

Andrew
0
 

Author Comment

by:ttnetworks
ID: 13605830
Hi,

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

Thanks for the help.

Andrew
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question