2010-11-28 108 views
22

如何获取应用程序路径? bin路径如何获取asp.net中的应用程序路径?

在asp.net

感谢的提前

+0

相关信息[这里]描述(https://stackoverflow.com/q/10951599/465053) 。 – RBT 2017-11-14 10:30:27

+0

另一篇文章谈论[在.Net中的Web应用程序中的服务器映射路径](https://stackoverflow.com/q/275781/465053) – RBT 2017-11-14 10:35:41

回答

3
Server.MapPath("~/bin") 

您还可以使用 Request.PhysicalApplicationPath

12

使用下面的代码片段:

string strPath = HttpContext.Current.Server.MapPath("~/bin"); 
9

我需要这个在app_start那里还没有HttpContext,因此RequestServer不是选项。

这奏效了:

System.Web.HttpRuntime.BinDirectory 
7
HttpContext.Current.Server.MapPath("~/bin") 

Application.StartupPath + "/bin" 

AppDomain.CurrentDomain.BaseDirectory + "/bin" 

,还有更多的是在blog

相关问题