Csharp/CSharp Tutorial/Directory Services/Host

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

List virtual hosts

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 );
          }
       }
    }
}