Name

AtEndOfStream (TextStream Object) — tsObj .AtEndOfStream

Synopsis

A Boolean value that indicates whether you have reached the end of the current text file. This is a read-only property.

Parameters

None

Example

The following code instantiates a FileSystemObject and a TextStream object. Then it uses the Read method to read one character at a time until the end of the file is reached. Notice that the use of the AtEndOfStream and AtEndOfLine properties are identical.

<%

' Set up constants.
Const constForReading      = 1 
Const constTristateFalse    = 0

' Dimension local variables. 
Dim fsoObject     ' FileSystemObject
Dim tsObject      ' TextStream Object
Dim strReturned   ' String variable to hold file contents.

' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
                "Scripting.FileSystemObject")
' Using the OpenTextFile method of fsoObject, create 
' a text file.
Set tsObject = _
    fsoObject.OpenTextFile("d:\docs\test.txt", _
    constForReading, constTristateFalse)

' Read one character at a time until the end of the 
' file has been reached
Do While Not tsObject.AtEndOfStream
   StrReturned = strReturned & tsObject.Read(1)
Loop
. . . [additional code]

%>

Notes

If you attempt to use the AtEndOfStream property with a text file opened for any purpose other than reading, you will receive an error.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.