Saturday, 10 August 2013

How to Open a File in QTP

Set file= fso.OpenTextFile("C:\file_location", ForWriting, True)//2nd argument can be ForReading, ForWriting, ForAppending
//3rd argument is “True” if new file has to be created if the specified file doesn’t exist else false, blank signify false.
How to read content from a file?
Use ReadLine() method
For example:
Set file= fso.OpenTextFile("C:\file_location", ForReading, True) //2nd argument should always be "ForReading" in order to read contents from a file
Do while file.AtEndofStream  True
      data = file.ReadLine()
      msgbox data
Loop

No comments:

Post a Comment