VBScript » TextStream » ReadAll

Version: 2.0

Syntax:
object.ReadAll

This method reads the entire contents of a text file and returns it as a string.

This method reads the entire contents of a text file and returns it as a string.

Examples

Code:
<%
dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\somefile2.txt")
text.Write "A quick example of the ReadAll method"
text.close
set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
contents = readfile.ReadAll
readfile.close
Response.Write "The file contains the following text - '"
contents "'."
%>
Output:
"The file contains the following text - 'A quick example of the ReadAll method'.