This blog has moved http://www.sharplogic.com/blogs/ed

This blog has moved here<!--meta http-equiv="refresh" content="0;url=http://www.sharplogic.com/blogs/ed"-->

One Way To Enumerate Virtual Directories On The Local Machine

I had a need to list the IIS directories available on my local machine, along with their local paths. There is a lot of cool WMI stuff to support things like this for IIS 6, but since I'm using XP I can't use it. I found it to be quite challenging to find code for this on the Web, so here's the code in case anyone else runs across the same challenge in the future:

using DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/1/Root")

foreach (DirectoryEntry child in root.Children)

{                      

      if (child.SchemaClassName == "IIsWebVirtualDir")

      {

            Console.WriteLine(string.Format("{0}: {1}", child.Name, child.Properties["Path"][0]));

      }

}

Let me know if there are better ways to do this.

Posted: Nov 08 2004, 06:20 PM by EdKaim | with no comments
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)