方法一:

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

方法二:

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

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

我推荐使用第二种

有时候可能出现找不到类的情况,请引用System.Web.dll

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2021-05-19
猜你喜欢
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案