我看到了全世界最好看的眼睛。 揉眼睛的手还有双眼皮。

C# 相对路径 Server.MapPath

上一篇 / 下一篇  2012-07-20 15:28:44 / 个人分类:C#

Server.MapPath 需添加引入using System.Web
 

 ./当前目录
/网站主目录
../上层目录
~/网站虚拟目录

如果当前的网站目录为E:\wwwroot   应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\company\news\show.asp
在show.asp页面中使用
Server.MapPath("./")   返回路径为:E:\wwwroot\company\news
Server.MapPath("/")    返回路径为:E:\wwwroot
Server.MapPath("../")   返回路径为:E:\wwwroot\company
Server.MapPath("~/")   返回路径为:E:\wwwroot\company
server.MapPath(request.ServerVariables("Path_Info")) 
Request.ServerVariables("Path_Translated")  
上面两种方式返回路径为 D:\wwwroot\company\news\show.asp

 

TAG:

 

评分:0

我来说两句

Open Toolbar