Server.MapPath 的使用方法

在写ASP程序的时候,尤其是用到FSO组件来生成一些文件夹或者文件的时候,经常要用到路径这个概念,但是我们又不能实际操作服务器,所以虚拟路径这时候就显的特别重要,其实大部分情况,我们都是用的虚拟路径。以下就虚拟路径这个概念总结了一下: ./当前目录 /根目录 ../上层目录(相对当前来说)

如果当前的网站目录为D:\wwwroot    浏览的页面路径为D:\wwwroot\company\news\show.asp

在show.asp页面中使用

           Server.MapPath("./")   返回路径为:D:\wwwroot\company\news

                               Server.MapPath("/")    返回路径为:D:\wwwroot

                              Server.MapPath("../")    返回路径为:D:\wwwroot\company

 server.MapPath(request.ServerVariables("Path_Info"))

 Request.ServerVariables("Path_Translated") 

上面两种方式返回路径为 D:\wwwroot\company\news\show.asp

posted @ 2013-11-21 10:56  妮妮盘  阅读(340)  评论(0编辑  收藏  举报