/ / If the virtual directory is named "Webtest", first reference in the project
//System.directoryservices.dll, then
Using System.directoryServices;
Protected system.directoryServices.directoryentry Dirroot DIRECTORY DIRROOT
?
1, add a new virtual directory
DirectoryEntry newvirdir = Dirroot.children.Add ("Webtest", "IisWebVirtualdir");
NewVirdir.Invoke ("AppCreate", TRUE;
Newvirdir.commitchanges ();
Dirroot.commitchanges ();
2, change the virtual directory properties
// Virtual directory properties are more common: AccessRead, AccessWrite, AccessExecute, AccessScript, Defaultdoc, Enabledefaultdoc, Path, etc.
DirectoryEntry Dirport = Dirroot.children.Find ("Webtest", "Iisvirtualdir");
Dirport .properties ["AccessRead"] [0] = True;
3. Delete the virtual directory
DirectoryEntry Dirport = Dirroot.children.Find ("Webtest", "Iisvirtualdir");
Dirport.Invoke ("Appdelete", true);
Dirroot.commitchanges ();
or:
Object [] part = new object [2];
Part [0] = "IisWebVirtualdir";
Part [1] = "Webtest";
Dirroot.Invoke ("delete", part);
Dirroot.commitchanges ();