Asp. net method summary for getting the current directory

  • 2020-06-19 10:07:32
  • OfStack

Method 1:

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

Method 2:

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

Method 3:
string sPath = Page.Server.MapPath("/");

I recommend the second one


Related articles: