如何在asp.net中获取应用程序路径?
如何获取应用程序路径? bin路径
在asp.net中
提前致谢
获取ASP.NET应用程序在服务器上的虚拟应用程序根路径。
Request.ApplicationPath;
http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx
ResolveUrl("~/bin");
Server.MapPath("~/bin")
您还可以使用HostingEnvironment.ApplicationPhysicalPath属性。
使用以下代码段:
string strPath = HttpContext.Current.Server.MapPath("~/bin");
HttpContext.Current.Server.MapPath("~/bin") Application.StartupPath + "/bin" AppDomain.CurrentDomain.BaseDirectory + "/bin"
以及博客中描述的更多内容
我在app_start
需要这个,那里还没有HttpContext
,因此Request
和Server
不是选项。
这样就可以了:
System.Web.HttpRuntime.BinDirectory
Server.MapPath("~/bin")
您还可以使用Request.PhysicalApplicationPath