파일 포인터가 TextStream 파일의 끝에 있는 경우 true를 반환하고, 그렇지 않으면 false를 반환합니다. 읽기 전용입니다.
구문
object.AtEndOfStream
인수
Object: 필수. 항상 TextStream 객체의 이름입니다.
주석
AtEndOfStream 등록정보는 읽기가 가능하도록 열려 있는 TextStream 파일에만 적용되며, 그렇지 않으면 오류가 발생합니다.
다음 코드는 AtEndOfStream 등록정보의 사용을 보여줍니다.
예 1:
Function ReadEntireFile(filespec)
Const ForReading = 1
Dim fso, theFile, retstring
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filespec, ForReading, False)
Do While theFile.AtEndOfStream <> True
retstring = retstring & theFile.ReadLine
Loop
theFile.Close
ReadEntireFile = retstring
End Function
' Usage
Dim fileContent
fileContent = ReadEntireFile("C:\Path\To\Your\File.txt")
예 2:
Function ReadUntilString(filespec, searchString)
Const ForReading = 1
Dim fso, theFile, line, foundString
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filespec, ForReading, False)
foundString = False
Do While theFile.AtEndOfStream <> True And foundString = False
line = theFile.ReadLine
If InStr(line, searchString) > 0 Then
foundString = True
End If
Loop
theFile.Close
If foundString Then
ReadUntilString = "String found: " & line
Else
ReadUntilString = "String not found."
End If
End Function
' Usage
Dim result
result = ReadUntilString("C:\Path\To\Your\File.txt", "searchString")