Comprehensive, categorized, searchable collection of links to ASP & ASP.NET resources...
ASP.NET Directory

Applications
Assembly & Controls
Books & Media
Community
Other ASP.NET Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

Powerful high Performance ASP.NET & SQL Server Forum Software
ASP Directory

Applications
ASP.NET Directory
Books & Media
Community
Components
Other ASP Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

Newsgroups

Participate in over
100 ASP & ASP.NET related newsgroups right here @ Fuzzy Software...

.NET Framework
- .net.faqs
- .net.framework
- .net.general
- .net.setup
- .net.scripting
- .net.xml

Web Services
- aspnet.webservices
- msdn.soaptoolkit
- msdn.webservices

SQL Server
- sqlserver.setup
- sqlserver.prog...
- sqlserver.tools

Classic ASP
- asp.db
- asp.general
- asp.components

Scripting
- scripting.jscript
- scripting.remote
- scripting.vbscript
- scripting.wsh

All newsgroups...

ASP Built-in
Objects Reference


Application Object
ObjectContext Object
Request Object
Response Object
Server Object
Session Object

Personalise Fuzzy
Make Homepage
Link To Fuzzy
Bookmark This Page

Add our directory to your site in less than
2 minutes...



Dundas Charts - Click for download








Whats New!
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 is 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 support relative path syntax (.) or (..). For example, the following relative path, ../MyDir/MyFile.txt, returns an error.

The MapPath method does not check whether the path it returns is valid or exists on the server.

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.

Examples

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.

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

<%= server.mappath(Request.ServerVariables("PATH_INFO"))%><BR>
 

produces the 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. The following scripts

<%= server.mappath("data.txt")%><BR>
<%= server.mappath("script/data.txt")%><BR>
 

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. The following scripts

<%= server.mappath("/script/data.txt")%><BR>
<%= server.mappath("\script")%><BR>
 

produce the following output

c:\inetpub\script\data.txt<BR>
c:\inetpub\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. The following scripts

<%= server.mappath("/")%><BR>
<%= server.mappath("\")%><BR>
 

produce the following output

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

Applies To

Server Object






$10/mo & 3 Months FREE!

InstantKB.NET - Complete ASP.NET knowledge base management solution...

Receive all the latest quality ASP
& ASP.NET content direct to your inbox. Sign-up to our newsletter.






DevDirect.com - Tools and Components for Software Developers

kbAlertz.com

DevBuilder.org

Bipin Joshi



More partners...

InstantForum.NET - rich-text ASP.NET enabled forums
  10140 ASP & ASP.NET resources in over 483 categories and growing daily...
Fuzzy Software - asp / asp.net resources, tutorials, code, scripts, applications, components, newsgroups, hosts and much more... Sitemap 0 1 4