try
{
string method = "Recycle";
string AppPoolName = this.textBox2.Text.Trim();
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool");
findPool.Invoke(method, null);
appPool.CommitChanges();
appPool.Close();
this.textBox1.Text = string.Format("回收应用程序池{0}成功", AppPoolName, method);
}
catch (Exception ex)
{
throw ex;
}