下面的代碼實現遍歷 IIS 6應用程序池的一個方法

下面的代碼實現遍歷 IIS 6應用程序池的一個方法:

System.DirectoryServices.DirectoryEntry appPoolRoot = new System.DirectoryServices.DirectoryEntry(@"IIS://localhost/W3SVC/AppPools");
//得到默認應用程序池的方法可以直接使用 IIS://localhost/W3SVC/AppPools/DefaultAppPool
System.Collections.IEnumerator AppPoolEnumer = appPoolRoot.Children.GetEnumerator();
while (AppPoolEnumer.MoveNext())
{
  System.DirectoryServices.DirectoryEntry EntryPool = (System.DirectoryServices.DirectoryEntry)AppPoolEnumer.Current;
  System.DirectoryServices.PropertyCollection properties = EntryPool.Properties;
  System.Collections.IDictionaryEnumerator propertiesEnumer = properties.GetEnumerator();
  textBox1.Text += "應用程序池名稱 = " + EntryPool.Name + System.Environment.NewLine + "____________________________________________" + System.Environment.NewLine;
  while (propertiesEnumer.MoveNext())
  {
    System.DirectoryServices.PropertyValueCollection propertyvalue = (System.DirectoryServices.PropertyValueCollection)propertiesEnumer.Value;
    if (propertyvalue.Count > 1)
    {
      for (int j = 0; j < propertyvalue.Count; j++)
      {
        textBox1.Text += "Name=" + propertiesEnumer.Key.ToString() + "  Value= " + propertyvalue[j] + "--";
      }
    }
    else
    {
      textBox1.Text += "Name=" + propertiesEnumer.Key.ToString() + "  Value= " + propertyvalue[0] + System.Environment.NewLine;
    }
  }



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1062846

 
發佈了49 篇原創文章 · 獲贊 1 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章