please dont rip this site
Platform SDK: IIS SDK
      [IIS 5.0] [IIS 5.1] [IIS 6.0]

Server.MapPath

The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax

Server.MapPath( Path)

Parameters

Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash (\), the MapPath method returns a path as if Path were a full, virtual path. If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the .asp file being processed.

Remarks

The MapPath method does not check whether the path it returns is valid or exists on the server. MapPath is not available to the Session.OnEnd and the Application.OnEnd events.

Because the MapPath method maps a path regardless of whether the specified directories currently exist, you can use the MapPath 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.

caution Caution  For security reasons, the AspEnableParentPaths property has a default value set to FALSE. Scripts will not have access to the physical directory structure unless AspEnableParentPaths is set to TRUE.

Example

For the examples below, the file Data.txt is located in the directory, C:\Inetpub\Wwwroot\Script, along with the Test.asp file that contains the following scripts. The C:\Inetpub\Wwwroot directory is set as the server's home directory.

The following example uses the server variable PATH_INFO to map the physical path of the current file.

<%=index.html Server.MapPath(Request.ServerVariables("PATH_INFO"))%><BR>

The preceding script produces the following output:

c:\inetpub\wwwroot\script\test.asp<BR>

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.

<%=index.html Server.MapPath("data.txt")%><BR>

<%= Server.MapPath("script/data.txt")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot\script\data.txt<BR>
c:\inetpub\wwwroot\script\script\data.txt<BR>

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.

<%=index.html Server.MapPath("/script/data.txt")%><BR>

<%= Server.MapPath("\script")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot\script\data.txt<BR>
c:\inetpub\wwwroot\script<BR>

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.

<%=index.html Server.MapPath("/")%><BR>

<%= Server.MapPath("")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot<BR>
c:\inetpub\wwwroot<BR>

The following example demonstrates how you can use relative paths to return the relative physical path to the page that is being viewed in the Web browser.

<%=index.html Server.MapPath("../")%><BR>

<%= Server.MapPath("..")%><BR>

Applies To

Server Object

See Also

Requirements

Platforms: Windows 2000 with IIS 5.0 installed, Windows XP with IIS 5.1 installed, Windows Server 2003 family with IIS 6.0 installed

Platform SDK Release: February 2003
What did you think of this topic?
Order a Platform SDK CD


file: /Techref/language/asp/OBJ/ref_vbom_serommp.htm, 6KB, , updated: 2003/5/15 13:13, local time: 2024/11/26 20:41,
TOP NEW HELP FIND: 
18.118.255.51:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/techref/language/asp/OBJ/ref_vbom_serommp.htm"> Server.MapPath</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .