Read Text

Opens a textfile and shows contents

<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 2504 Downloads 860


JeffSmith
26
File System Classic ASP
Revisions

v1.0