- ASP - Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


Link & Display Text Files
Linking and displaying text files within a single document is a snap in asp.  All of the text files contain the title as the first line.  The first line will be read and hyperlinked in the default view.  When clicked the file name is passed to the same page as a querystring variable.  Providing that the text document exists (this is to prevent errors from user typing in the address bar) the full contents of the document will be displayed.  This is an excellent way to make copybooks and file layouts available online.
View the Output
Text View
Print View
Mail this Link
Download the Code

<body bgcolor=#FFFFFF>
<title> & Display Text Files)</title>


if u_file = "" then

' Get the top level directory info
dir_info = request.servervariables("appl_physical_path")

' Get the rest of the directory info without the first / 
dir_info = dir_info + right(request.servervariables("script_name"),(len(request.servervariables("script_name"))-1)) 

' Split the directory info by /

' Count the number of splits

set directory=server.createobject("scripting.filesystemobject")
set allfiles=directory.getfolder(server.mappath("../"&g_input(num_inputted)))

' Lists all the files found in the directory
For each directoryfile in allFiles.files 

' Removes ASP pages from view 
if (right(,3)) <> "asp" then 

set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath(

read_text = act.readline


<a href=<%
' Write out the name of the page
response.write request.servervariables("script_name") %>
' Write out the name of the document
response.write server.urlencode( %>
' Write out the first line of the document
response.write server.htmlencode(read_text) %>
'End check for any pge other than ASP
end if 

' End for next loop to list documents
' End check for querstring input

set fso = createobject("scripting.filesystemobject")

' Check to see if the file in the querystring exists
' (This prevents user input in the address bar from causing errors)
if fso.FileExists (server.mappath(u_file)) then 
' Open the file and read it
set act = fso.opentextfile(server.mappath(u_file))
read_text = act.readall

' Write the contents of the document ot the browser
Response.Write "<pre>" & server.htmlencode(read_text) & "</pre>"

' If the file in the querystring does not exist
' Display and eror message

There was a problem displaying the requested item<br>
Please go <a href=<%= request.servervariables("script_name")%>>back</a> and select again<%

' End check for file existence
end if 

' End check for querystring value
end if




ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3