当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP MapPath 方法
The MapPath method maps a specified path to a physical path.
MapPath作用是显示指定路径的物理路径(绝对路径)。
Note: This method cannot be used in Session.OnEnd and Application.OnEnd.
注意:这个方法不能在Session_OnEnd以及Application_OnStart内使用
Server.MapPath(path) |
| Parameter 参数 | Description 描述 |
|---|---|
| path | Required. A relative or virtual path to map to a physical path. If this parameter starts with / or , it returns a path as if this parameter is a full virtual path. If this parameter doesn't start with / or , it returns a path relative to the directory of the .asp file being processed 必要参数。显示相对路径或虚拟路径的物理路径(绝对路径)。如果参数以“/”、“”开始,它将返回虚拟路径的整个物理路径;如果参数不是以“/”、“”开始的,它将返回所执行的asp文件所处文件夹的相对路径。 |
| Example 1 For the example below, the file test.asp is located in C:InetpubWwwrootScript. The file Test.asp (located in C:InetpubWwwrootScript) contains the following code: <%
response.write(Server.MapPath("test.asp") & "<br />")
response.write(Server.MapPath("script/test.asp") & "<br />")
response.write(Server.MapPath("/script/test.asp") & "<br />")
response.write(Server.MapPath("script") & "<br />")
response.write(Server.MapPath("/") & "<br />")
response.write(Server.MapPath("") & "<br />")
%> Output: c:inetpubwwwrootscripttest.asp c:inetpubwwwrootscriptscripttest.asp c:inetpubwwwrootscripttest.asp c:inetpubwwwrootscript c:inetpubwwwroot c:inetpubwwwroot Example 2 How to use a relative path to return the relative physical path to the page that is being viewed in the browser: <%
response.write(Server.MapPath("../"))
%> or <%
response.write(Server.MapPath(".."))
%> |
评论 (0) All