You do it:
Final = TS.ReadAll
Do Until TS.AtEndOfStream
TempS = TS.ReadLine
Final = Final & TempS & vbCrLf
Loop
You should check AtEndOfStream before calling ReadAll, something like:
If TS.AtEndOfStream Then
Final = ""
Else
Final = TS.ReadAll
Do Until TS.AtEndOfStream
TempS = TS.ReadLine
Final = Final & TempS & vbCrLf
Loop
End If
As a note, however, you have a logical error: ReadAll will read the entire file in memory. Therefore, subsequently calling ReadLine will not return anything. Either use ReadAll, or parse the input using string manipulations, or just call ReadLine. Do not use both options.
source
share