List all websites in IIS c#

前端 未结 3 1250
无人共我
无人共我 2020-12-05 11:06

Is there a way to list all active websites that exist within IIS using c#?

Thanks

Sp

相关标签:
3条回答
  • 2020-12-05 11:22

    If anyone is intrested i used the following

    var files = Directory.GetFiles(directory, "*",SearchOption.AllDirectories);
    sizeInBytes = (from file in files let fileInfo = new FileInfo(file) select fileInfo.Length).Sum();
    
    0 讨论(0)
  • 2020-12-05 11:29

    For IIS 7 you can use Microsoft.Web.Administration.dll (C:\Windows\System32\inetsrv) and the following code

            var iisManager = new ServerManager();
            SiteCollection sites = iisManager.Sites;
    
    0 讨论(0)
  • 2020-12-05 11:39

    Here's an article explaining how this could be done using classes from the System.DirectoryServices namespace as well as the Microsoft.Web.Administration namespace which was introduced with IIS 7.

    0 讨论(0)
提交回复
热议问题