Following is an ASP mappath demonstration.
Copy and paste this code snippet into your .asp page, then view the page in your web browser.
http://yoursite.com/page.asp
We suggest using mappath instead of using an absolute path in your coded applications.
*Note that no edit to the code needs to be made at all to run this demonstration.*
ASP MapPath Demo
<%
response.write "" &_
"ASP Server.MapPath Demonstration
The "File.txt" file does not actually exist;"&_
"unless you created one that is, this is used as a demonstration of how to use mappath.
" &_
"For a more dramatic effect, place this file in a sub folder of your website's root folder.
" &_
"This path will take you to the folder this file is currently running in.
" &_
"| ASP Path: | server.mappath ("file.txt") |
" &_
"| Output: | " & server.mappath("file.txt") & " |
" &_
"
" &_
"This path will take you to the root of your website, notice the use of the "/" at the beginning of the path.
" &_
"| ASP Path: | server.mappath ("/file.txt") |
" &_
"| Output: | " & server.mappath("/file.txt") & " |
" &_
"
For a more detailed explanation of Server.MapPath please visit this Helpful originalAttribute="href" originalPath="'http://www.w3schools.com/ASP/met_mappath.asp'>Helpful" originalAttribute="href" originalPath="'http://www.w3schools.com/ASP/met_mappath.asp'>Helpful" Site" &_
""
%>