简体   繁体   English

如何获取网站/应用程序的物理路径

[英]How to get physical path of a website/app

How do I get the physical path of a website (for example "MyWebSite") from C#? 如何从C#获取网站的物理路径(例如“ MyWebSite”)? My server is IIS 7. 我的服务器是IIS 7。

Using msdeploy from c#, I have the following code: 从C#使用msdeploy,我有以下代码:

var deployBaseOptions = new DeploymentBaseOptions
{
    ComputerName = connectOption.UrlPublishing,
    UserName = connectOption.UserName,
    Password = connectOption.Password,
    AuthenticationType = "Basic",
};

Use Server.MapPath 使用Server.MapPath

ie var path = Server.MapPath("~"); var path = Server.MapPath("~");

you can use the following: 您可以使用以下内容:

var path=HttpContext.Current.Server.MapPath.Tostring();

Reference here 这里参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM