List virtual hosts : Host « Directory Services « C# / CSharp Tutorial






using System;
using System.Data;
using System.DirectoryServices;

public class MainClass{

   public static void Main() {
       DirectoryEntry directoryEntry1 = new DirectoryEntry();
       directoryEntry1.Path = "IIS://localhost/W3SVC/1/ROOT";

       foreach( DirectoryEntry entry in directoryEntry1.Children ) {
          if ( entry.SchemaClassName == "IIsWebVirtualDir" ) {
             //Console.WriteLine( entry.Name );
             Console.WriteLine( entry.Properties[ "Path" ].Value );
          }
       }
    }
}








34.8.Host
34.8.1.List virtual hosts