代码如下:
            const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT";
            string physicalPath = FilePath;
            DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot);            DirectoryEntry tbEntry = root.Children.Add(VirtualName, root.SchemaClassName);            tbEntry.Properties["Path"][0] = physicalPath;
            tbEntry.Invoke("AppCreate", true);            tbEntry.Properties["AccessRead"][0] = true;
            tbEntry.Properties["ContentIndexed"][0] = true; ;
            tbEntry.Properties["DefaultDoc"][0] = "index.asp,Default.aspx";
            tbEntry.Properties["AppFriendlyName"][0] = VirtualName;
            tbEntry.Properties["AccessScript"][0] = false;
            tbEntry.Properties["DontLog"][0] = false;
            //tbEntry.Properties["AuthFlags"][0] = 0;
            //tbEntry.Properties["AuthFlags"][0] = 1;
            tbEntry.CommitChanges();