Reading a text file with FileSystemObject
I'm doing a VBscript. I have had some success so far, with populating recordsets and moving files.
The next thing I need to do is read a textfiile. The code I am using seems to be a textbook example but I can't get it to work.
Set fso = CreateObject("Scripting.FileSystemObject")
Set stream = fso.OpenTextFile(pathToTextFile, 1) '1 means ForReading
Do Until stream.AtEndOfStream
Ln = stream.ReadLine
I purchased a VBscript editor which has a debugger. When I step through the code, I verified that "PathToTextFile" has the correct value and I verified that this textfile does indeed contain a lot of text.
The code isn't throwing any errors. However, the variable "Ln" remains an empty string. It's not reading the text. It's just a regular plain text file editable in Wordpad or Notepad.