Skip to main content

Posts

Showing posts from October, 2013

Control the text file pointer

We could have faced a problem like getting back the reading location of a opened text file to re-read or re-search the file from beginning ... We don't have a right approach to do this in VBScript using FileSystemObject without close and reopening the file. But we could do using STREAM object without reopen ... Dim myFileStream Set myFileStream = CreateObject("ADODB.Stream") myFileStream.CharSet = "UTF-8" myFileStream.LineSeparator = 13 myFileStream.Open myFileStream.LoadFromFile("C:\MyFile.txt") msgbox myFileStream.ReadText(-2) 'Returns first line myFileStream.Position = 0 msgbox myFileStream.ReadText(-2) 'returns first line again as expected myFileStream.Close posted from Bloggeroid