I want to open a text file and then search some specified
text in it and then replace that text with some other text
i found that text in .txt but do not know how to replace
that text can any body help me. if possible put the code
for qtp

Answer Posted / rico

Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\working\replace.txt",
ForWriting, True)
f.Write "QTP QTP RFT QTP QTP RFT QTP QTP"
Set f = fso.OpenTextFile("c:\working\replace.txt",
ForReading)
ReadAllTextFile = f.ReadAll
newText = Replace( ReadAllTextFile, "QTP", "QTPRO")
Set textFile = fso.OpenTextFile
( "C:\working\replace.txt", ForWriting )
textFile.WriteLine newText
f.Close

Is This Answer Correct ?    12 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can anybody let me know how to test the Drag and drop feature of the column in a .net application...eg..i hav to test the drag and drog feature of a table(swftable) in a application..plze help!!

1768


Explain types of output values?

581


I would like to directly import XL file and work on that XL file directly in QTp script in that XL sheet need to allocate workbench,XL sheet and generate two bar graphs automatically how to do that? plz let me know any answers?

1573


How you can find length of array in qtp?

561


How many types of run modes are there in qtp?

605






What is the syntax to call one script from another?

548


What is the syntax to call one script from another? And what can be the syntax to call one “action” in another?

711


If I am scripting Web-based Surveys using QTP that open up differently but at the exact same point require a username and password can I automate that username and password for all the surveys some how using QTP?

1454


How to read a text file from QC using QTP. I would like to do something like this. But instead read a file from QC and NOT from my local drive. Set fso = CreateObject("Scripting.FileSystemObject") Set InputFile = fso.OpenTextFile("C:\test.txt", ForReading) Thanks

2771


How many types of parameters are available in quicktest professional (qtp)?

597


what is meant by Implicit and explicit requirements?

3638


What are the major/ important methods, functions in QTP we use realtime testing

2282


any body can you help me what is the script to automate an comand promt

1993


if there is a web table of having row and colmns.a button is placed at 2nd row's 3rd column which is worked for both edit and delete..how to write script for the button to test both operation on the web table using desriptive programing.. plz help me on script wheather using getroproperty Q2)what is the command for taking valiue from a web table in qtp

23982


how to know no.of mails in our g mail by using vb-script

1791