'##################################################################
'Working with Files through FileSystemObject in VB Script for QTP/UFT
'Author: Vikas
'##################################################################
'1.Working with Files in VB Script
'1.1 How to create a text file in QTP/UFTusing VB Script(Visual Basic Script) ?
Dim objFso,objFile
Set objFso=CreateObject("Scripting.FileSystemObject")' Fso object can be used to
operate over both Files and Folder
'CreateTextFile method of File object creates a new text file ,other parameter "True"
is used to overwrite the exisitng file having same name
Set objFile=objFso.CreateTextFile( "D:\Music\myTextFile.txt",true)
'Output :
'An empty file has been created
'1.2 How to write in file using VB Script in UFT/QTP ?
' Write method is used to write text into the file
'objFile.Write("Hello World")
'Output:
'1.3 How to write blank lines in File using VB Script ?
'
''WriteBlankLines takes parameter as interger number ,and writes content to the
'next line if given "1"
'objFile.WriteBlankLines(1)
'objFile.Write ("Hello Mike")
'Output ::
'and writes content to the line after gap of one line if parameter given as "2"
'objFile.WriteBlankLines(2)
'objFile.Write ("Hello Mike")
'Output:
'1.4 How to write text stream at the end (or append) in File using VB Script ?
'
''WriteLine Method writes at the end of "Hello World"
'objFile.WriteLine(".Hello Leela")
''Output:
0 comments: