国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > IIS > 正文

C#列表所有IIS站點(diǎn)以及相關(guān)站點(diǎn)屬性

2024-08-29 03:13:56
字體:
供稿:網(wǎng)友
中國最大的web開發(fā)資源網(wǎng)站及技術(shù)社區(qū),

using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.windows.forms.design;
using system.directoryservices;
using system.reflection;
using system.text.regularexpressions;

int totalservercount=0;  
   
   directoryentry rootfolder = new directoryentry("iis://localhost/w3svc");
   //totalservercount=rootfolder.children.schemafilter.count;
   
   foreach (directoryentry child in rootfolder.children)
   {          
    if (child.schemaclassname == "iiswebserver")
    {      
     totalservercount+=1;        
    }
   }
   //循環(huán)獲取所有站點(diǎn)詳細(xì)屬性寫入數(shù)組中
   string [] arrayserverid = new string[totalservercount];//站點(diǎn)標(biāo)識(shí)符
   string [] arrayserverip = new string[totalservercount];//站點(diǎn)主機(jī)頭 
   string [] arrayserverport = new string[totalservercount];//站點(diǎn)主機(jī)頭 
   string [] arrayserverheader = new string[totalservercount];//站點(diǎn)主機(jī)頭
   string [] arrayserverpath = new string[totalservercount];//站點(diǎn)主機(jī)頭 
   string [] arrayservercomment = new string[totalservercount];//站點(diǎn)主機(jī)頭

   string [] arrayserverbinds = new string[totalservercount];//站點(diǎn)主機(jī)頭

   
   string currentserverbindings;//綁定主機(jī)頭ip端口字符串
   char[] a=":".tochararray();
   string [] currentbingdings =new string[2]; 

   int i=0;
   foreach (directoryentry child in rootfolder.children)
   {          
    if (child.schemaclassname == "iiswebserver")
    {       
     arrayserverid.setvalue(child.name.tostring(),i);
     arrayservercomment.setvalue(child.properties["servercomment"].value.tostring(),i);

     currentserverbindings=child.properties["serverbindings"].value.tostring();
     
     currentbingdings=currentserverbindings.split(a);

     arrayserverip.setvalue(currentbingdings[0],i);
     arrayserverport.setvalue(currentbingdings[1],i);
     arrayserverheader.setvalue(currentbingdings[2],i);

     
     foreach (directoryentry rootchild in child.children)
     {
      if((rootchild.schemaclassname == "iiswebvirtualdir")&&(rootchild.name.tostring()=="root"))
      { 
       if(rootchild.properties["path"].value==null)
       {
        arrayserverpath.setvalue("",i);
       }
       else
       {
        arrayserverpath.setvalue(rootchild.properties["path"].value.tostring(),i);
       }
      }
     }
    
     i+=1;
    }
   }


   //寫入到datagrid中去
   //循環(huán)從數(shù)組中讀取數(shù)據(jù)
   for(i=0;i<totalservercount;i++)
   {
    
    listview1.items.add((i+1).tostring());   
    listview1.items[i].subitems.add(arrayserverid.getvalue(i).tostring());
    listview1.items[i].subitems.add(arrayservercomment.getvalue(i).tostring());
    listview1.items[i].subitems.add(arrayserverip.getvalue(i).tostring());
    listview1.items[i].subitems.add(arrayserverport.getvalue(i).tostring());
    listview1.items[i].subitems.add(arrayserverheader.getvalue(i).tostring());
    listview1.items[i].subitems.add(arrayserverpath.getvalue(i).tostring());
    
  
   } 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 泌阳县| 昭苏县| 阿拉尔市| 青河县| 东丰县| 涿鹿县| 德保县| 卢湾区| 吉水县| 嘉义市| 西乡县| 西乌| 望江县| 广饶县| 安宁市| 小金县| 岳池县| 湛江市| 英山县| 海宁市| 太谷县| 隆回县| 扎兰屯市| 米林县| 阳城县| 胶州市| 景泰县| 灵宝市| 潼南县| 育儿| 灌云县| 乐东| 东兰县| 尚义县| 南木林县| 荣昌县| 玛沁县| 富阳市| 荥阳市| 龙陵县| 阜城县|