asp.net 获取当前目录的几个方法

来源:互联网 发布:linux内核移植教程 编辑:程序博客网 时间:2024/05/01 13:59

方法一:

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

方法二:

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

 //("images/")是当前虚拟目录下的任意目录

方法三:
string sPath = Page.Server.MapPath("images/");   //("images/")是当前虚拟目录下的任意目录

另:获取全路径中的文件名

string  sFile = System.IO.Path.GetFileName(sFile);