Sunday, 27 April 2014

QTP - UFT - How to open a text file using VBScript or How to open a flat file using VBScript





Open text file can be opened using "Scripting.FileSystemObject"

Syntax
filename = "c:\sample.txt"
strmode = 2
Set o1 = Createobject("Scripting.Filesystemobject")
If o1.FileExists(filename) = true Then
    set r1 = o1.OpenTextFile filename,strmode
 else
    ExitTest
End If
Msgbox r1.readall()

strMode represents the File Read mode and Any Text file can be opened in the following modes

ForReading  1  Open a file for reading only. You can't write to this file.
ForWriting 2 Open a file for writing.
ForAppending 8 Open a file and write to the end of the file.


No comments:

Post a Comment