[英]Can I use DirectoryEntry to list sites within IIS Express
I am on Windows XP. 我在Windows XP上。 We have Windows 2008 Servers.
我们有Windows 2008服务器。 Need to run IIS Express until we get workstations or virtual machines with newer version of local OS for the real IIS 7.X.
需要运行IIS Express,直到获得具有用于实际IIS 7.X的较新版本的本地操作系统的工作站或虚拟机为止。
Can I use DirectoryEntry to list my Sites and Virtual Directories when I run c# code under IIS Express? 在IIS Express下运行c#代码时,可以使用DirectoryEntry列出我的站点和虚拟目录吗? I have examples for setting up the Virtual Directories under IIS Express so that I think I have covered.
我有一些在IIS Express下设置虚拟目录的示例,因此我认为已经介绍了。 Now I want to list them to ensure they exist.
现在,我想列出它们以确保它们存在。
Anyone know how to do this in C#? 有人知道如何在C#中执行此操作吗? Just a small snippet of what I have been trying causes com exceptions...
我尝试的一小段代码会导致com异常...
DirectoryEntry iisServer = new DirectoryEntry("IIS://localhost/W3SVC/1");
DirectoryEntry folderRoot = iisServer.Children.Find("Root", "/");
var children = folderRoot.Children;
you can try something like this 你可以尝试这样的事情
void ListVirtualDirectories(string serverName, int siteId)
{
DirectoryEntry iisServer = new DirectoryEntry("IIS://" + serverName + "/W3SVC/" + siteId + "/ROOT");
foreach (DirectoryEntry webDir in iisServer.Children)
{
if (webDir.SchemaClassName.Equals("IIsWebVirtualDir"))
Console.WriteLine("Found virtual directory {0}", webDir.Name);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.