spacerLokken Logo
spacerLokken Binary Logo
spacer spacer spacer spacer
File Reader
Language:   Server Sided ASP - JavaScript
Author:   Jon Lokken
Date:   4-8-2005

Using the ASP file system object to read a file.  This will even get virtual include files that are included in that file.  It does not render the file as ASP though.  It only does a read on the file and return a text string.

<%@ LANGUAGE="JavaScript" %>
<% Response.buffer=true %>

objMyFSO= Server.CreateObject("Scripting.FileSystemObject");

* This version of getPage returns a string of the page contents
* with no return characters in the page. This is for use in
* the side Menu Contents.
* Author: Jon Lokken - 4.8.2005
function getPage(pathOfPage){
var serverPath = Server.MapPath(pathOfPage);
var doesFileExist = objMyFSO.FileExists(serverPath);

var pageTStream = objMyFSO.OpenTextFile(serverPath);
var pageContents = "";

while(! pageTStream.AtEndOfStream){
var temp = "" + pageTStream.Readline();

var temp2 = temp.replace(virtualBeg, "");
temp2 = temp2.replace(virtualEnd, "");
temp = temp.replace(virtualInclude, getPage(temp2));

pageContents = pageContents + temp + "";
return pageContents;
return String("The page "+pathOfPage+" has been moved or deleted from the server.");


Feel free to use this code I have written.  I only ask that you leave my name in the comments.  I take no responsibility for this code working, imply no warranty as to it's validity, and will not be held liable if you decide to try it.  I am only trying to help out others so they don't have to struggle with the same problems as me...

Associated Sites: Jon Lokken - | Amy Lokken - | Isabel Lokken - | Elizabeth Lokken - | - | - | Lokken Consulting -
Author: Jon Lokken -