Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling file in QTP
#1
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
Yes, Open your file in append mode instead of write mode.

Reply
#3
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
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
Great Saket. It worked. but what was the reason of not running of the old line?

Thanks,

Ajit
Reply
#6

Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)