您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> asp.net编程 >> 正文

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

作者:佚名    责任编辑:admin    更新时间:2022-06-22

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

方法一:

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

方法二:

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

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

我推荐使用第二种