Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling file in QTP
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi All,

I know how to create a text file and how to write in them. Is there any way to update them? i mean not to overwrite the file but to add another lines?
Please help.

Thanks,

Ajit
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
Yes, Open your file in append mode instead of write mode.

Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi Saket,
I am trying as you have said but getting the invalid call procedure or argument.
My code is:
Code:
Dim fso, tf
   Set fso = CreateObject("Scripting.FileSystemObject")

    If (fso.FileExists ("c:\testfile.txt")) = True Then
Set tf = fso.OpenTextFile("c:\testfile.txt", ForAppending, True)

Else
   Set tf = fso.CreateTextFile("c:\testfile.txt", True)
  
   End If
   ' Write a line with a newline character.
'  tf.WriteLine("CashOnHand    TotalPortfolioWorth    ShareHoldingValue")
   ' Write a line.
   tf.Write (CashOnHand&"    "&TotalPortfolioWorth&"    "&ShareHoldingValue)
   tf.Close

Please correct me where i am wrong.

Thanks;

Ajit
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
you have not defined 'ForAppending' anywhere in the code
add 'ForAppending = 8' this line at top. or

use below statement -
Set tf = fso.OpenTextFile("c:\testfile.txt", 8, True)

Reply
#5
Solved: 10 Years, 8 Months, 3 Weeks ago
Great Saket. It worked. but what was the reason of not running of the old line?

Thanks,

Ajit
Reply
#6
Solved: 10 Years, 8 Months, 3 Weeks ago
refer the link for more details on this
http://msdn.microsoft.com/en-us/library/...S.85).aspx

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Difference between error handling and exception handling venkatbatchu 6 25,729 12-11-2018, 05:11 PM
Last Post: smitapawar610
  QTP hangs on handling error window dtamilarasan 1 3,607 06-04-2013, 02:45 PM
Last Post: basanth27
  QTP script to save the generated .csv file and excel file priya elangovan 0 4,147 08-29-2012, 04:17 PM
Last Post: priya elangovan
  Handling Flash components through QTP...? venkat_1241 1 3,824 06-23-2010, 10:55 AM
Last Post: Saket

Forum Jump:


Users browsing this thread: 1 Guest(s)