当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP MapPath 方法

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP MapPath 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 350 ::
收藏到网摘: n/a

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内使用

Syntax
语法

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文件所处文件夹的相对路径。

Examples
举例

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

登陆 | 还没注册?