// If the virtual directory named "Webtest", first referenced in the project //System.DirectoryServices.dll, then using System.DirectoryServices; protected System.DirectoryServices.DirectoryEntry dirroot; 1, add a new virtual directory DirectoryEntry newVirDir = dirroot. Children.Add ("Webtest", "IisWebVirtualDir"); NewVirdir.Invoke ("AppCreate", True; NewVirdir.commitchanges (); Dirroot.commitchanges (); 2, Changing the virtual directory properties // virtual directory properties is more commonly used are: AccessRead, AccessWrite, AccessExecute, AccessScript, DefaultDoc, EnableDefaultDoc, Path and the like DirectoryEntry Dirport = dirroot.Children.Find ( "Webtest", "IIsVirtualDir"); Dirport .Properties [ "AccessRead"] [0] = true; 3 Delete virtual directory DirectoryEntry Dirport = Dirroot.children.Find ("Webtest", "IisvirtualDir"); Dirport.Invoke ("AppDelete"; Dirroot.commitchanges (); or: Object [] part = new object [2 ]; Part [0] = "IisWebVirtualdir"; part [1] = "Webtest"; Dirroot.Invoke ("delete", part); Dirroot.commitchanges ();