All Properties
TextStream Object
Property: TextStream.AtEndOfStream
Implemented in version 2.0
object.
AtEndOfStream
The
AtEndOfStream
property returns a Boolean value. If the file pointer is positioned at the end of the file, the value is
True
. Otherwise, the value is
False
. The
TextStream
object must be open for reading or an error will occur when using this method.
The following code uses the
AtEndOfStream
property to get the last character in text file.
Code:
<%
dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\somefile2.txt")
text.Write "Find the last character in the text file"
text.close
set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
do while readfile.AtEndOfStream <> true
contents = readfile.Read(1)
loop
readfile.close
Response.Write "The last character in the text file is '" & contents & "'."
%>
Output:
"The last character in the text file is 'e'."
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information