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

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

c#讀取IIS中的站點相關(guān)屬性代碼

2024-08-29 03:13:56
字體:
供稿:網(wǎng)友

private void combobox1_selectedindexchanged(object sender, system.eventargs e)
  {
   string currentservercomment=combobox1.selecteditem.tostring();
   string currentsitenum = getwebsitenum(currentservercomment);
   string rootpath = "iis://localhost/w3svc";
   string currentsitepath =rootpath+"/"+currentsitenum;   
   directoryentry siteentry = new directoryentry(currentsitepath); 

   string currentserverbindings=siteentry.properties["serverbindings"].value.tostring();
   char[] a=":".tochararray();
   string [] currentbingdings = null;   
   currentbingdings=currentserverbindings.split(a);
   string currentserverip=currentbingdings[0];
   string currentserverport=currentbingdings[1];
   string currentserverheader=currentbingdings[2];
   string currentserverhost="";
   string currentserverpath="";

   foreach (directoryentry child in siteentry.children)
   {
    
    if((child.schemaclassname == "iiswebvirtualdir")&&(child.name=="root"))
    {
     currentserverpath = child.properties["path"].value.tostring();
     
    }
   }
 

   textbox2.text=currentserverip;
   textbox3.text=currentserverport;
   textbox4.text=currentserverpath;
   textbox5.text=currentserverheader;
   textbox6.text=currentserverhost;
  }

/// <summary>
  /// 根據(jù)站點名稱獲取站點標(biāo)識符
  /// </summary> 
  
  public string getwebsitenum(string sitename)
  {

   regex regex = new regex(sitename);
   string tmpstr;
   string entpath = "iis://localhost/w3svc";
   directoryentry ent =new directoryentry(entpath); 

   foreach(directoryentry child in ent.children)

   {
    if(child.schemaclassname == "iiswebserver")
    {
     if(child.properties["serverbindings"].value != null)
     {
      tmpstr = child.properties["serverbindings"].value.tostring();
      if(regex.match(tmpstr).success)
      {
       return child.name;
      }
     }

     if(child.properties["servercomment"].value != null)

     {
      tmpstr = child.properties["servercomment"].value.tostring();
      if(regex.match(tmpstr).success)
      {
       return child.name;
      }
     }
    }
   }
   return "";
   
  }



收集最實用的網(wǎng)頁特效代碼!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 峨边| 桑日县| 长沙县| 台州市| 定结县| 涿鹿县| 呼图壁县| 临夏市| 和平县| 双桥区| 牡丹江市| 钟山县| 揭东县| 蚌埠市| 吉木乃县| 雷波县| 兴化市| 中宁县| 扶绥县| 阿合奇县| 梧州市| 玛沁县| 丰原市| 宁河县| 新建县| 莱阳市| 揭阳市| 德阳市| 益阳市| 高州市| 旺苍县| 虎林市| 兰溪市| 龙井市| 双城市| 耒阳市| 西林县| 祁连县| 英德市| 如东县| 凤台县|