Tuesday, April 19, 2011

QTP : Create a text file using File System Object

'Create a file system object
Set fso=createObject("Scripting.FileSystemObject")

'Create a file over the file system object -
' Parameters -
' 1 - Path of the object
' 2 - True - denotes overwrite the file if it exists
set file1=fso.CreateTextFile("C:\test.txt",True)

' Write the text into the file
 file1.write("hello world");

' file 1 is a TextStream Object
' Close the file
file1.close

No comments:

Post a Comment

Please add value. Sharing is caring