How to read text file using UFT

We access the text file in UFT by using the filesystemobject. The UFT will read all the data line by line. Below is the sample code which can be used to read any text file.

Set FileSysObj=CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Set txtFile = FileSysObj.OpenTextFile("<textfile>", ForReading, True)


Do Until inputFile.AtEndOfStream 
 msgbox inputFile.ReadLine
 msgbox inputFile.Line
Loop

inputFile.close

You can use any conditional statement in the code which can be used to extract the required data from the text file.

Comments

Post a Comment

Popular posts from this blog

UFT - Resolving scrolling issue if object is not visible

How to create a zip folder using VBScript

how to access the excel file as database in UFT?