MapPath 方法可把指定的路径映射到服务器上相应的物理路径上
发布时间:2023-10-12 15:09:35 所属栏目:Asp教程 来源:
导读:MapPath 方法可把指定的路径映射到服务器上相应的物理路径上。
注意:此方法不能用于 Session.OnEnd 和 Application.OnEnd 中。
语法
Server.MapPath(path)
参数 描述
path 必需。映射为物理路径
注意:此方法不能用于 Session.OnEnd 和 Application.OnEnd 中。
语法
Server.MapPath(path)
参数 描述
path 必需。映射为物理路径
MapPath 方法可把指定的路径映射到服务器上相应的物理路径上。 注意:此方法不能用于 Session.OnEnd 和 Application.OnEnd 中。 语法 Server.MapPath(path) 参数 描述 path 必需。映射为物理路径的相对路径或绝对路径。如果该参数以 / 或 \ 开头,则返回完整的虚拟路径。如果该参数不以 / 或 \ 开头,则返回相对于正在被处理的 .asp 文件的路径。 实例 实例 1 举例,文件 test.asp 位于 C:\Inetpub\wwwroot\Script。 文件 Test.asp (位于 C:\Inetpub\wwwroot\Script) 包含下列代码: <% response.write(Server.MapPath("test.html") & "<br>") response.write(Server.MapPath("script/test.html") & "<br>") response.write(Server.MapPath("/script/test.html") & "<br>") response.write(Server.MapPath("script") & "<br>") response.write(Server.MapPath("/") & "<br>") response.write(Server.MapPath("") & "<br>") %> 输出: c:inetpubwwwrootscripttest.html c:inetpubwwwrootscriptscripttest.html c:inetpubwwwrootscripttest.html c:inetpubwwwrootscript c:inetpubwwwroot c:inetpubwwwroot 实例 2 如何使用一个相对路径来返回到达正在浏览器中查看的页面的相对物理路径: <% response.write(Server.MapPath("../")) %> 或者: <% response.write(Server.MapPath("..")) %> (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐