C#列表所有IIS站点以及相关站点属性
来源:互联网 发布:crm软件定制 编辑:程序博客网 时间:2024/04/30 00:32
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;
}
}
//循环获取所有站点详细属性写入数组中
string [] arrayServerID = new string[TotalServerCount];//站点标识符
string [] arrayServerIP = new string[TotalServerCount];//站点主机头
string [] arrayServerPort = new string[TotalServerCount];//站点主机头
string [] arrayServerHeader = new string[TotalServerCount];//站点主机头
string [] arrayServerPath = new string[TotalServerCount];//站点主机头
string [] arrayServerComment = new string[TotalServerCount];//站点主机头
string [] arrayServerBinds = new string[TotalServerCount];//站点主机头
string currentServerBindings;//绑定主机头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中去
//循环从数组中读取数据
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());
}
- C#列表所有IIS站点以及相关站点属性
- c#读取IIS中的站点相关属性代码
- webshell下查找所有IIS站点配置
- C#操纵本地IIS(建站点)
- C# 获取IIS站点及虚拟目录信息
- c# 修改IIS 站点framework版本号
- C#创建IIS站点或者虚拟目录
- C# 编程创建 IIS 7 站点
- IIS站点中部署WCF项目 - C#
- C# 获取IIS站点及虚拟目录信息
- C# 获取IIS站点及虚拟目录信息
- IIS站点管理类
- IIS 发布站点常见问题
- IIS 站点重定向
- IIS站点配置进阶
- IIS站点的部署
- IIS站点部署
- IIS新建站点
- 在JAVA的GUI上放置图片,并在图片上输出半透明文字
- 【转】C 语言吧 · 问题资料大全【转】(二)
- 两小儿辩“日”
- 【转】C 语言吧 · 问题资料大全【转】(三)
- 一个数据录入系统
- C#列表所有IIS站点以及相关站点属性
- SQL语句的优化(1)——注释优化
- 配置VNC 使window下vnc访问linux的桌面
- gcc与g++
- 大家在asp.net 中支持ubb的~~用的是什么控件呀?
- 误会钉子且慢下手宽大
- Nokia手机型号与symbian版本号
- SQL Server2000 索引结构及其使用
- 读javaWeb开发记录-类装载器