惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
博客园_首页
M
MIT News - Artificial intelligence
雷峰网
雷峰网
GbyAI
GbyAI
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
S
SegmentFault 最新的问题
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 【当耐特】
V
Visual Studio Blog
月光博客
月光博客
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
云风的 BLOG
云风的 BLOG
美团技术团队
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队

博客园 - winkingzhang

Build 2016概览 WinRT开发系列之编程语言:功能和效率 WinRT开发系列之基础概念:WinRT不是…… VS2010 Extension实践(3)——实现自定义配置 [VS2010 Extension]PowerExtension.GoToDefinition VS2010 Extension实践(2) VS2010 Extension实践 如何通过反射调用带有ref或者out的参数的方法[迁移] Win7硬盘安装和移动硬盘访问出错的修复办法[迁移] zt. Windows Mobile开发文章收藏 [WPF]在Style中设置ToolTip的问题分析 [WPF]RadioButton在Group的Header区部分不响应鼠标选择的bug分析 WPF模式思考 (zt) Visual Studio 调试器 Application Request Routing and the IIS 7.0 Web Management Service Reference Resources for MOSS and WSS FileSystemWatcher事件多次触发的解决方法 ASP.NET Application Life Cycle CAS and Native Code
How to Get IIS Web Sites Information Programmatically
winkingzhang · 2008-10-31 · via 博客园 - winkingzhang

http://blogs.msdn.com/helloworld/archive/2008/10/31/how-to-get-iis-web-sites-information-programmatically.aspx

How to Get IIS Web Sites Information Programmatically

I needed to get the location of IIS log files on my servers, after doing a quick investigation, I am quite amazed on how much information are exposed via managed code.

This snippet will return the name of the sites and the location of the log files.

foreach (DirectoryEntry Site in new DirectoryEntry("IIS://" + System.Environment.MachineName + "/w3svc").Children)
if (String.Compare(Site.SchemaClassName, "IIsWebServer", StringComparison.OrdinalIgnoreCase) == 0)
Console.WriteLine(Site.Properties["ServerComment"].Value.ToString() + " == " + Site.Properties["LogFileDirectory"].Value.ToString());

To get more information about what fields and method you can access, please refer to this MSDN doc: http://msdn.microsoft.com/en-us/library/ms524487.aspx.

Just remember, in Vista/Windows Server 2008, you will need to run that code with elevated privilege.