Like us on Facebook

February 8, 2015

FileSystemObject(UFT/QTP):Access File through VB Script

  2/08/2015 No comments


'##################################################################
'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:

Author: Vikas Pandey

He is a software and web developer working for renowned European investment bank.He loves to share knowledge through blogging whatever he knows and encourages others as well to share the same to make world a better place to live.

0 comments:

.
© 2014-2015 Informational Digit : How-To & Tech Guides. The content is copyrighted to Vikas Pandey and may not be reproduced on other websites. WP themonic converted by Bloggertheme9.
TOP