国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 葫芦岛市| 辽阳市| 邹城市| 宜春市| 江永县| 响水县| 济南市| 怀化市| 遵化市| 资兴市| 巴彦淖尔市| 布拖县| 彭州市| 合作市| 正镶白旗| 旌德县| 巨野县| 郴州市| 仙居县| 抚顺市| 丹东市| 台南市| 历史| 满洲里市| 油尖旺区| 金门县| 衡阳市| 柯坪县| 奉新县| 五指山市| 太原市| 哈尔滨市| 张家界市| 龙泉市| 福建省| 响水县| 凤阳县| 大足县| 周口市| 石林| 旬阳县|