61,824
社区成员




//相关变量参数部分略...
DirectoryEntry root = new DirectoryEntry(@"IIS://localhost/W3SVC");
DirectoryEntry site = (DirectoryEntry)root.Invoke("GetObject", "IIsWebServer", siteID);
DirectoryEntry webroot = (DirectoryEntry)site.Invoke("GetObject", "IIsWebVirtualDir", "root");
Console.WriteLine("正在创建虚拟目录...");
virDir = webroot.Children.Add(strName, "IIsWebVirtualDir");
virDir.Invoke("AppCreate", true);
virDir.CommitChanges();
virDir.Properties["AppIsolated"][0] = 2;
virDir.Properties["Path"][0] = strPath;
virDir.Properties["AccessFlags"][0] = 513;
virDir.Properties["FrontPageWeb"][0] = 1;
virDir.Properties["AppRoot"][0] = "LM/W3SVC/" + siteID + "/Root/" + strName;
virDir.Properties["AppFriendlyName"][0] = strName;
virDir.Properties["AccessRead"][0] = true;
virDir.Properties["AccessScript"][0] = true;
virDir.Properties["AccessWrite"][0] = false;
virDir.Properties["EnableDirBrowsing"][0] = false;
virDir.Properties["EnableDefaultDoc"][0] = true;virDir.CommitChanges();
webroot.CommitChanges();
site.CommitChanges();