Read Text

Opens a textfile and shows contents

Public
Tested
My Own Work
<html>
<head>
</head>
<body>
<%
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Dim objTextStream

const strFileName = "d:\websites\jeffasmithcom\read_text\test.txt"
const fsoForReading = 1

If objFSO.FileExists("d:\websites\jeffasmithcom\read_text\test.txt") then
'The file exists, so open it and output its contents
Set objTextStream = objFSO.OpenTextFile(strFileName, fsoForReading)
Response.Write "<PRE>" & objTextStream.ReadAll & "</PRE>"
objTextStream.Close
Set objTextStream = Nothing
Else
'The file did not exist
Response.Write strFileName & " was not found."
End If

'Clean up
Set objFSO = Nothing
%>
</body>
</html>

Views 2975 Downloads 997

Classic ASP File System
JeffSmith
26
Revisions

v1.0