我正在编写一个web应用程序部署验证工具,我需要检查Web应用程序和虚拟文件夹的物理文件夹结构。
在C#中如何做到这一点呢?或者更一般地说,通过C#代码与IIS交互?
发布于 2011-03-25 19:41:52
我强烈建议您使用IIS来实现出色的Microsoft.Web.Administration管理功能。
ServerManager serverManager = new ServerManager();
// get the site (e.g. default)
Site site = serverManager.Sites.FirstOrDefault(s => s.Name == "Default Web Site");
// get the application that you are interested in
Application myApp = site.Applications["/Dev1"];
// get the physical path of the virtual directory
Console.WriteLine(myApp.VirtualDirectories[0].PhysicalPath);提供:
F:\Dev\Branches\Dev1
https://stackoverflow.com/questions/5431713
复制相似问题