// Delete a virtual directory public static void Delete(string machine, string name) { using (DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryTool.RootType.IIS, machine)) { using (DirectoryEntry entry = DirectoryEntryTool.GetVirtualDirectory(machine, root, name)) { root.Children.Remove(entry); root.CommitChanges(); } } }
// Create a virtual directory public static void Create(string machine, VirtualDirectory item) { using (DirectoryEntry root = DirectoryEntryTool.GetRoot(DirectoryEntryTool.RootType.IIS, machine)) { using (DirectoryEntry entry = DirectoryEntryTool.GetVirtualDirectory(machine, root, item.Name)) { root.CommitChanges(); entry.CommitChanges(); SetProperties(entry, item); } } }