Brinkster Working Examples


<% '-------------------------------------------------------------------------Sever.MapPath Dim sCurrentLocation, sRootDirectory sCurrentLocation = Server.MapPath ("exFindYourPath.asp")'-----------------here we set a variable equal to the path of this file. Response.Write ("This function will produce a physical path based on the information you pass it (''within the quotation marks'') and the current path of the file you are working out of. ") Response.Write ("It will not give you an error if the information you pass it is incorrect. It just assumes the information is correct.

") Response.Write ("So, double check the result with your directory structure.

") Response.Write ("Using <%Server.MapPath (''FileInUse.asp'')%> you can find the path of the file you are currently using.

") Response.Write ("Using Server.MapPath you can see that this file is located at:
") Response.Write (sCurrentLocation & "

") '-------------------------------------------------------------------------Referencing Other Files Response.Write ("
Referencing Other Files
") Response.Write ("
") Response.Write ("Let's say we want to reference a file called ''Test.asp''. We know this file is located at ''WebRoot\TestFiles\Test.asp''. ") Response.Write ("The file we a currently working in is located at ''Webroot\Production\Working.asp''. So, how do we reference ''Test.asp'' from the file ''Working.asp''?

") Response.Write ("Just like this. <%Server.MapPath (''\TestFiles\Test.asp'')%>

") Response.Write ("By putting the ''\'' at the beginning we are telling ASP to start at the WebRoot directory and move into the TestFiles directory looking for the Test.asp file.

") Response.Write ("Now let's say we want to reference a file called ''FindMe.asp''. We know this file is located at ''WebRoot\Production\Search\FindMe.asp''. ") Response.Write ("We are still working at ''Webroot\Production\Working.asp''. So how do we get to ''FindMe.asp''.

") Response.Write ("With a small change. <%Server.MapPath (''Search\FindMe.asp'')%>

") Response.Write ("This time we did not use the ''\''. We are starting from our current directory (Production) going up one (to Search) and then referencing FindMe.asp.

") '-------------------------------------------------------------------------Referencing Your DataBase Response.Write ("
Referencing Your DataBase
") Response.Write ("
") Response.Write ("As a Premium Member your database can be located outside of you webroot directory. This is done so that it can not be downloaded when a person references it in the URL.

") '--------------------------------------------------- some parsing code that will display 6 "\" from the left. Dim iCounter, iLocation, sTemp, iTemp, iLength sTemp = sCurrentLocation iLength = Len(sCurrentLocation) iCounter = 0 While iCounter <= 3 iTemp = InStr(sTemp, "\") iLocation = iTemp + iLocation iLength = iLength - iTemp sTemp = Right(sTemp, iLength) iCounter = iCounter + 1 Wend sRootDirectory = Left(sCurrentLocation, instr(lcase(sCurrentLocation),"\webroot")-1) '--------------------------------------------------- end of parseing Response.Write ("The path should look like this:
") Response.Write ("
") Response.Write (sRootDirectory) & "\database\YourDB.mdb

" Response.Write ("
Make sure you put your database in the Database directory. The Database directory is the only directory with write permissions.

") Response.Write ("
Referencing Include Files
") Response.Write ("
") Response.Write ("There are two different ways to reference an Include.

") Response.Write ("<!-- #Include Virtual=''/includes/FileName.asp --> or <!-- #Include File=''includes\FileName.asp'' -->

") Response.Write ("With Include Virtual you can only reference files within your virtual directories (everything back to the WebRoot). ") Response.Write ("The same principles apply to Include Virtual as they did with Server.MapPath. Again, if you put a ''/'' at the beginning of the reference you will start at the WebRoot directory and so on.

") Response.Write ("With Include File you can use the entire path to reference the file.
") Response.Write ("<!-- #Include File=''" & sRootDirectory & "webroot\includes\FileName.asp'' -->

") Response.Write ("Or, you can start at the directory you are in. In this case we are starting in the WebRoot directory, then moving into the Includes directory, referencing FileName.asp.
") Response.Write ("<!-- #Include File=''includes\FileName.asp'' -->

") Response.Write ("You can not put a ''\'' at the beginning to start at the WebRoot directory when using Include File.") Response.Write ("

") %>