原创:C# .Net 获取应该程序池中站点数量,并列举站点和属性

txtPath.Text= IIS://Localhost/W3SVC/AppPools/DefaultAppPool;

 

DirectoryEntry pool = new DirectoryEntry(txtPath.Text.Trim());
            lvPoolProties.Items.Clear();
            ////显示属性
            //foreach (string name in pool.Properties.PropertyNames)
            //{
            //    ListViewItem item = new ListViewItem(name+":"+ pool.Properties[name].Value.ToString());
            //    lvPoolProties.Items.Add(item);
            //}

            object[] s = pool.Invoke("EnumAppsInPool", null) as object[];
            MessageBox.Show(s.Length.ToString());

            foreach (object o in s)
            {
                ListViewItem item = new ListViewItem(o.ToString());
                lvPoolProties.Items.Add(item);
            }

你可能感兴趣的:(.net)