【发布时间】:2011-09-16 10:53:48
【问题描述】:
我编写了一个 Windows 应用程序。我的问题是:我一直在 IIS 6.0 中列出虚拟目录,代码如下。我必须找到所选虚拟目录的 pyhsical 路径。
此外,DirectoryEntry 类有一个名为properties 的属性。但是,我不能使用它。最后,我收到以下错误。
The directory cannot report the number of properties
代码:
try
{
string serverName = "localhost";
string VirDirSchemaName = "IIsWebVirtualDir";
iisServer = new DirectoryEntry("IIS://" + serverName + "/W3SVC/1");
DirectoryEntry folderRoot = iisServer.Children.Find("Root",VirDirSchemaName);
return folderRoot.Children;
}
catch (Exception e)
{
throw new Exception("Error while retrieving virtual directories.",e);
}
【问题讨论】: