Thursday, April 21, 2011

VBScript Code | Reading text from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)
a=QTPfile.ReadLine
QTPfile.Close
Print a

No comments:

Post a Comment