Operate the virtual directory in IIS

xiaoxiao2021-03-06  85

If the virtual directory is named "Chinabs", first reference 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 ("Chinabs", "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 ("Chinabs", "IisVirtualdir");

Dirport .properties ["AccessRead"] [0] = True;

3. Delete the virtual directory

DirectoryEntry Dirport = Dirroot.children.Find ("Chinabs", "IisVirtualdir");

Dirport.Invoke ("Appdelete", true);

Dirroot.commitchanges ();

or:

Object [] part = new object [2];

Part [0] = "IisWebVirtualdir";

Part [1] = "chinabs";

Dirroot.Invoke ("delete", part);

Dirroot.commitchanges ();

转载请注明原文地址:https://www.9cbs.com/read-106451.html

New Post(0)