/// <summary> /// Delete an app pool /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool DeleteAppPool(string name) { if (IISAppPool.Exsit(name) == false) { return(false); } IISAppPool appPool = IISAppPool.OpenAppPool(name); appPool._entry.DeleteTree(); return(true); }
/// <summary> /// Open a application pool and return an IISAppPool instance /// </summary> /// <param name="name">application pool name</param> /// <returns>IISAppPool object</returns> public static IISAppPool OpenAppPool(string name) { string connectStr = "IIS://localhost/W3SVC/AppPools/"; connectStr += name; if (IISAppPool.Exsit(name) == false) { return(null); } DirectoryEntry entry = new DirectoryEntry(connectStr); return(new IISAppPool(entry)); }