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

 更新时间:2013年07月30日 10:05:32   作者:  
有时候可能出现找不到类的情况,请引用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("/");

我推荐使用第二种

相关文章

最新评论