Asp.NET获取文件及其路径

时间:2022-07-24 18:21:32
【相对路径】
 
Request.ApplicationPath
/src
Path.GetDirectoryName(HttpContext.Current.Request.RawUrl )
//src//Xiaoshe
Context.Request.Path
/src/Xiaoshe/Xiaoshe_New.aspx
Context.Request.CurrentExecutionFilePath
/src/Xiaoshe/Xiaoshe_New.aspx
Context.Request.FilePath
/src/Xiaoshe/Xiaoshe_New.aspx
HttpContext.Current.Request.RawUrl 
/src/Xiaoshe/Xiaoshe_New.aspx
HttpContext.Current.Request.Url
http://localhost:1344/src/Xiaoshe/Xiaoshe_New.aspx
TemplateSourceDirectory
/src/Controls
 
 
【绝对路径】
 
Server.MapPath("./") 
E://Wonsoft//Pro2//src//Xiaoshe//
Server.MapPath("") 
E://Wonsoft//Pro2//src//Xiaoshe
Context.Request.PhysicalApplicationPath
E://Wonsoft//Pro2//src//
Context.Request.PhysicalPath 
E://Wonsoft//Pro2//src//Xiaoshe//Xiaoshe_New.aspx
MapPathSecure(TemplateSourceDirectory)
E://Wonsoft//Pro2//src//Controls string
 
 
【其他】
 
Control.ResolveClientUrl(string relativeUrl)
 
Control.ResolveUrl(string relativeUrl)
 引自:http://blog.csdn.net/wonsoft/article/details/5570520