ASP.NET获取各级目录Server.MapPath详解全
server.mappath(
"/") 应用程序根目录所在的位置 如 c:\inetpub\wwwroot\
server.mappath(
"~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:c:\inetpub\wwwroot\example\
server.mappath(
"./") 表示所在页面的当前目录 注:等价于server.mappath(
"") 返回 server.mappath(
"")所在页面的物理文件路径 :返回路径为:e:\wwwroot\company\news
server.mappath(
"../")表示上一级目录 :返回路径为:e:\wwwroot\company
app_code文件夹下 类获取路径 httpruntime.appdomainapppath : 注:等效于server.mappath(
"~")。
server.mappath(request.servervariables(
"path_info")),request.servervariables(
"path_translated") 上面两种方式返回路径为 d:\wwwroot\company\news\show.aspx
server.mappath(request.applicationpath);和httpruntime.appdomainapppath有何区别?对于:http:
//localhost/dlltest/dlayer.aspx
server.mappath(
".")---d:\wwwroot\dlltest
httpruntime.appdomainapppath---d:\wwwroot\dlltest\
一个有最后的
'\ ',一个没有
如对本文有疑问,
点击进行留言回复!!
网友评论