asp.net对iis中的虚拟目录进行操作
//假如虚拟目录名为"webtest",先在项目中引用
//system.directoryservices.dll,再
using system.directoryservices;
protected system.directoryservices.directoryentry dirroot;
1、添加新的虚拟目录
directoryentry newvirdir = dirroot.children.add("webtest","iiswebvirtualdir");
newvirdir.invoke("appcreate",true);
newvirdir.commitchanges();
dirroot.commitchanges();
2、更改虚拟目录属性
//虚拟目录的属性较常用的有:accessread,accesswrite,accessexecute,accessscript,defaultdoc,enabledefaultdoc,path等
directoryentry dirport = dirroot.children.find("webtest","iisvirtualdir");
dirport .properties["accessread"][0] = true;
3、删除虚拟目录
directoryentry dirport = dirroot.children.find("webtest","iisvirtualdir");
dirport.invoke("appdelete",true);
dirroot.commitchanges();
或者:
object[] part = new object[2];
part[0] = "iiswebvirtualdir";
part[1] = "webtest";
dirroot.invoke("delete",part);
dirroot.commitchanges();