zoukankan      html  css  js  c++  java
  • How to Get IIS Web Sites Information Programmatically

    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.


    To be the apostrophe which changed “Impossible” into “I’m possible”
    ----------------------------------------------------
    WinkingZhang's Blog (http://winkingzhang.cnblogs.com)
    GCDN(http://gcdn.grapecity.com/cs)
  • 相关阅读:
    SQL 代码片段
    SQL
    Python List
    python_enumerate用法
    HashMap记录
    Brute Force(暴力算法)
    python解析html文件,提取标签中一个元素
    每五分钟统计一次数据
    grep
    expect
  • 原文地址:https://www.cnblogs.com/winkingzhang/p/1323763.html
Copyright © 2011-2022 走看看