c#根据端口号获取IIS网站物理路径和网站名称
来源:互联网 发布:macbookair下载软件 编辑:程序博客网 时间:2024/06/06 01:09
private const string constIISRoot = "IIS://localhost/w3svc";
private Hashtable GetWebPathAndWebName(string PortNum)
{
Hashtable ht = new Hashtable();
Regex regex = new Regex(PortNum);
string tmpStr;
DirectoryEntry rootIISEntry = new DirectoryEntry(constIISRoot);
foreach (DirectoryEntry entry in rootIISEntry.Children)
{
if (entry.SchemaClassName == "IIsWebServer")
{
if (entry.Properties["ServerBindings"].Value != null)
{
tmpStr = entry.Properties["ServerBindings"].Value.ToString();
if (regex.Match(tmpStr).Success)
{
ht.Add("name",entry.Properties["ServerComment"].Value.ToString());
ht.Add("path", GetWebsitePhysicalPath(entry));
break;
}
}
}
}
return ht;
}
/// 得到网站的物理路径
/// </summary>
/// <param name="rootEntry">网站节点</param>
/// <returns></returns>
public string GetWebsitePhysicalPath(DirectoryEntry rootEntry)
{
string physicalPath = "";
foreach (DirectoryEntry childEntry in rootEntry.Children)
{
if ((childEntry.SchemaClassName == "IIsWebVirtualDir") && (childEntry.Name.ToLower() == "root"))
{
if (childEntry.Properties["Path"].Value != null)
{
physicalPath = childEntry.Properties["Path"].Value.ToString();
}
else
{
physicalPath = "";
}
}
}
return physicalPath;
}
- c#根据端口号获取IIS网站物理路径和网站名称
- .NET 获取IIS中网站名称和属性
- .NET 获取IIS中网站名称和属性
- C#获取IIS中网站日志文件保存路径
- VBS获取本地IIS中网站的信息(IP、端口、站点名称)
- 获取网站虚拟目录下的物理路径
- asp.net获取网站目录物理路径
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- tomcat 部署网站 去掉端口号和项目名称
- tomcat 部署网站 去掉端口号和项目名称
- tomcat 部署网站 去掉端口号和项目名称
- Tomcat 部署网站 去掉端口号和项目名称
- C#获取本机IIS虚拟目录的物理路径
- 获取从 asp.net 网站的 IIS 站点名称
- 根据虚拟目录获取物理路径
- 修改IIS虚拟网站名称
- SetNeedsDisplay but drawRect not called
- 返回所有n位整数,每个整数里的值是单调递增的
- Java面试的问题附带答案
- sql语句
- C# 获取IIS站点及虚拟目录信息
- c#根据端口号获取IIS网站物理路径和网站名称
- iPhone中获取UIWebView内的html方法
- C#读取IIS信息
- 如何修改CEdit&CB中文本的字体大小及颜色
- c# 修改IIS 站点framework版本号
- C#创建IIS站点或者虚拟目录
- SQLite3中针对Objective-C的持久框架
- 大崩溃-正在降临的危机与金融风暴史(The Great Crash) 第四章 大 崩溃:不仅仅是股市
- Linux文件操作函数open close read write等示例