Sunday, December 12, 2010

VBScript Code | Appending text to 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 appends a text to a file. If the file does not exist, it creates the file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForAppending, True)
QTPfile.WriteLine("Myfirst line of text.")
QTPfile.Close

0 comments: