Codefixer - ASP tutorials, resources and software
ASP.NET Hosting with US & UK Data Centers!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Sunday 7 September
MembersPro PayPal - ASP Membership software

New MS SQL 2008 Available – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Server.Mappath Examples

Below are examples on how to use Server.MapPath. Server.MappPath takes a path as a parameter and returns the exact physical location of that file on the hard drive. Read more on Server.MapPath.

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

<%= Server.Mappath(Request.ServerVariables("PATH_INFO"))%>

So if c:\inetpub\wwwroot is the web root folder and the code above is in the file "server_mappath_examples.asp" in our codesnippets directory then it might display c:\inetpub\wwwroot\codesnippets\server_mappath_examples.asp

Please support our site by clicking on Google Ads

We can also use the Server.MapPath method to retrieve other file paths

'Our variable sCurrDir holds the current directory
sCurrDir = Server.MapPath(".")


'Our variable sParentDir holds the parent directory
sParentDir = Server.MapPath("..")


'Our variable sRootDir holds the root directory
sRootDir = Server.MapPath("/")





If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site.

ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software