public static bool DeleteAppPool(string name) { if (IISAppPool.IsExist(name) == false) { return(false); } IISAppPool appPool = IISAppPool.OpenAppPool(name); appPool._entry.DeleteTree(); return(true); }
public static IISAppPool CreateAppPool(string name) { DirectoryEntry Service = new DirectoryEntry("IIS://localhost/W3SVC/AppPools"); foreach (DirectoryEntry entry in Service.Children) { if (entry.Name.Trim().ToLower() == name.Trim().ToLower()) { return(IISAppPool.OpenAppPool(name.Trim())); } } DirectoryEntry appPool = Service.Children.Add(name, "IIsApplicationPool"); appPool.CommitChanges(); Service.CommitChanges(); return(new IISAppPool(appPool)); }