获取网站根目录的方法有几种如:

Server.MapPath(Request.ServerVariables["PATH_INFO"])
   Server.MapPath("/")

   Server.MapPath("~/")//当前代码文件所在的目录路径
   Server.MapPath("")//当前代码文件所在的目录路径
   Server.MapPath(".")
   Server.MapPath("../")
   Server.MapPath("..") 

      Page.Request.ApplicationPath

 

System.Web.HttpContext.Current.Request.PhysicalApplicationPath

和Server.MapPath("~/")效果是一样的。

Server.MapPath("~/");//无论代码所在的文件的、页面路劲是什么,永远返回 C:\Inetpub\wwwroot\EnglishClub\(就是当前程序运行的所在根目录)

相关文章:

  • 2021-10-28
  • 2021-12-07
  • 2021-11-12
  • 2021-11-23
  • 2022-02-04
  • 2021-08-01
  • 2021-08-11
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2021-09-06
  • 2021-11-27
  • 2022-12-23
  • 2021-09-01
相关资源
相似解决方案