140 lines
5.9 KiB
HTML
140 lines
5.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
|
|
<TITLE>MapPath</TITLE>
|
|
<SCRIPT LANGUAGE="JavaScript">
|
|
<!--
|
|
TempString = navigator.appVersion
|
|
if (navigator.appName == "Microsoft Internet Explorer"){
|
|
// Check to see if browser is Microsoft
|
|
if (TempString.indexOf ("4.") >= 0){
|
|
// Check to see if it is IE 4
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else {
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
}
|
|
}
|
|
else if (navigator.appName == "Netscape") {
|
|
// Check to see if browser is Netscape
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
//-->
|
|
</script>
|
|
<SCRIPT LANGUAGE="VBScript">
|
|
<!--
|
|
Sub Window_OnLoad()
|
|
Dim frmContents
|
|
On Error Resume Next
|
|
If Not Parent Is Nothing Then
|
|
Set frmContents = Parent.Contents
|
|
If Not frmContents Is Nothing Then
|
|
frmContents.Window.TOCSynch_Click
|
|
End If
|
|
End If
|
|
End Sub
|
|
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
|
|
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
|
|
<META NAME="MS.LOCALE" CONTENT="EN-US">
|
|
<META NAME="MS-IT-LOC" Content="Internet Information Services">
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
|
|
|
|
<H4><A NAME="_mappath"></A><SUP></SUP>MapPath</H4>
|
|
|
|
<P>The <B>MapPath</B> method maps the specified relative or virtual path to the corresponding physical directory on the server.</P>
|
|
|
|
<H6>Syntax</H6>
|
|
|
|
<P><B>Server.MapPath(</B> <I>Path</I> <B>)</B></P>
|
|
|
|
<P><B> </B></P>
|
|
|
|
<H6>Parameters</H6>
|
|
|
|
<DL>
|
|
<DT><I>Path</I></DT>
|
|
|
|
<DD>Specifies the relative or virtual path to map to a physical directory. If <I>Path </I>starts with either a forward (/) or backward slash (\), the <B>MapPath </B>method returns a path as if <I>Path </I>is a full virtual path. If <I>Path </I>doesn't start with a slash, the <B>MapPath </B>method returns a path relative to the directory of the .asp file being processed.</DD>
|
|
</DL>
|
|
|
|
<H6>Remarks</H6>
|
|
|
|
<P>The <B>MapPath </B>method does not check whether the path it returns is valid or exists on the server. <B>MapPath </B>is not available in the <B>Session.OnEnd </B>and the<B> Application.OnEnd </B>events.</P>
|
|
|
|
<P>Because the <B>MapPath </B>method maps a path regardless of whether the specified directories currently exist, you can use the <B>MapPath </B>method to map a path to a physical directory structure, and then pass that path to a component that creates the specified directory or file on the server.</P>
|
|
|
|
<P>For security reasons, the <A HREF="/iishelp/iis/htm/asp/apro00vn.htm">AspEnableParentPaths</A> property's default value was set to FALSE. Scripts will not have access to the physical directory structure unless <A HREF="/iishelp/iis/htm/asp/apro00vn.htm">AspEnableParentPaths</A> is set to TRUE.</P>
|
|
|
|
<H6>Example</H6>
|
|
|
|
<P>For the examples below, the file data.txt is located in the directory, C:\Inetpub\Wwwroot\Script, as is the test.asp file that contains the following scripts. The C:\Inetpub\Wwwroot directory is set as the server's home directory.</P>
|
|
|
|
<P>The following example uses the server variable <CODE>PATH_INFO</CODE> to map the physical path of the current file. </P>
|
|
|
|
<PRE><CODE><%= Server.MapPath(Request.ServerVariables("PATH_INFO"))%><BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The preceding script produces the output</P>
|
|
|
|
<PRE><CODE>c:\inetpub\wwwroot\script\test.asp<BR>
|
|
</CODE></PRE>
|
|
|
|
<P>Because the path parameters in the following examples do not start with a slash character, they are mapped relative to the current directory, in this case C:\Inetpub\Wwwroot\Script. </P>
|
|
|
|
<PRE><CODE><%= Server.MapPath("data.txt")%><BR>
|
|
<%= Server.MapPath("script/data.txt")%><BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The preceding scripts produce the following output</P>
|
|
|
|
<PRE><CODE>c:\inetpub\wwwroot\script\data.txt<BR>
|
|
c:\inetpub\wwwroot\script\script\data.txt<BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The next two examples use the slash characters to specify that the path returned should be looked up as complete virtual paths on the server. </P>
|
|
|
|
<PRE><CODE><%= Server.MapPath("/script/data.txt")%><BR>
|
|
<%= Server.MapPath("\script")%><BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The preceding scripts produce the following output</P>
|
|
|
|
<PRE><CODE>c:\inetpub\wwwroot\script\data.txt<BR>
|
|
c:\inetpub\wwwroot\script<BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The following examples demonstrate how you can use either a forward slash (/) or a backslash (\) to return the physical path to the home directory of the Web site root. </P>
|
|
|
|
<PRE><CODE><%= Server.MapPath("/")%><BR>
|
|
<%= Server.MapPath("\")%><BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The preceding scripts produce the following output</P>
|
|
|
|
<PRE><CODE>c:\inetpub\wwwroot<BR>
|
|
c:\inetpub\wwwroot<BR>
|
|
</CODE></PRE>
|
|
|
|
<P>The following examples demonstrate how you can use relative pathing to return the relative physical path to the page that is being viewed in the Web browser.</P>
|
|
|
|
<PRE><CODE><%= Server.MapPath("../")%><BR>
|
|
<%= Server.MapPath("..\")%><BR>
|
|
</CODE></PRE>
|
|
|
|
<H6>Applies To</H6>
|
|
|
|
<P><A HREF="/iishelp/iis/htm/asp/vbob7838.htm"><B>Server</B> Object</A> </P>
|
|
|
|
<H6>See Also</H6>
|
|
|
|
<P><A HREF="/iishelp/iis/htm/asp/apro00vn.htm">AspEnableParentPaths</A></P>
|
|
<hr class="iis" size="1">
|
|
<p align="center"><em><a href="../../../common/colegal.htm">© 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
|
|
</BODY>
|
|
</HTML>
|