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("/")

Get the best asp web hosting provider now and save 30%

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.