站长资源网络编程

Asp.net获取当前目录的方法小结

整理:jimmy2026/8/4浏览2
简介方法一:string sPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath)方法二:string sPath = System.Web.HttpContext.Current.Request.MapPath("/")

方法一:

string sPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath)

方法二:

string sPath = System.Web.HttpContext.Current.Request.MapPath("/")                                         

方法三:
string sPath = Page.Server.MapPath("/");

我推荐使用第二种