Press "Enter" to skip to content

Tag: IIS6.0

Win2003服务器IIS6.0在指定目录下创建虚拟目录[原创]

热度 2,033 度

在站点下指定images目录下创建upload虚拟目录

DirectoryEntry iisrootdirectory = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");

 iisrootdirectory.RefreshCache();

 foreach (DirectoryEntry child in iisrootdirectory.Children)  //循环遍历根目录下的images
 {
     if (child.Name.Contains("images"))
     {
         DirectoryEntry virtualdirectory = child.Children.Add("upload", "IIsWebVirtualDir");

         virtualdirectory.Properties["Path"].Insert(0, @"C:\TestWebSite\upload");

         virtualdirectory.Invoke("AppCreate", true);

         virtualdirectory.CommitChanges();

         iisrootdirectory.CommitChanges();

         virtualdirectory.Close();

         iisrootdirectory.Close();

     }
 }
Leave a Comment