如何获得IIS虚拟目录和放大器; Web应用程序的使用C#code物理路径? [英] How to get the IIS virtual dir & web application's physical paths with C# code?
本文介绍了如何获得IIS虚拟目录和放大器; Web应用程序的使用C#code物理路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写在C#中的Web应用程序部署验证工具。我需要检查网络领域应用和虚拟文件夹的物理文件夹结构。能在C#这样做吗?或者更一般地,通过C#code与IIS进行交互?
I am writing a web application deployment verification tool in C#. And I need to check the physical folder structures of Web Applicatons and Virtual Folders. Could this be done in C#? OR more generally, interact with IIS through C# code?
我发现这个链接并会读它回家。
I found this link and will read it back home.
感谢。
推荐答案
我会强烈建议使用的 Microsoft.Web.Administration 的DLL与IIS高超的管理功能。
I would strongly suggest using the Microsoft.Web.Administration dll for superb admin features with IIS.
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:\开发\分行\装置1
这篇关于如何获得IIS虚拟目录和放大器; Web应用程序的使用C#code物理路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文