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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / venki
Function Replacestring(filepath,find_string,replace_string)
Const ForReading = 1
Const ForWriting = 2
Dim obj,notepad,myline,newText
Set obj = CreateObject("scripting.FileSystemObject")
Set notepad=obj.OpenTextFile(filepath,ForReading)
Do Until notepad.AtEndOfStream
myline = notepad.readall
loop
msgbox myline
newText = Replace(myline ,find_string,replace_string)
Set notepad = obj.openTextFile(filepath, ForWriting )
notepad.WriteLine newText
notepad.Close
msgbox newText
end function
Call Replacestring("C:\New Folder\fade to
black.txt","me","you")'>mention your file path,string to
find,replacing string.
| Is This Answer Correct ? | 7 Yes | 2 No |
Hi, I Install QTP 9.2 in windows Vista. but it is not supporting IE. it is supporting only windows based application. could I change any setting in Vista for supporting IE.. ?? thanks in advance...
Hi Friends, Iam Beginner in QTP and i want to Try the software QTP. I checked the mercury site for QTP Trial version and i found QTP 9.0. The thing is that it supports windows 2000,Xp but not windows 98.And Iam using Windows 98 onlu and it's not possible for me to upgrade to windows 2000. Pls. guide me how to get the trial version of QTP which supports windows 98 Operating System The version may be 6.5 is ok for me.Thanks in Advance
Hi All , How can we decicde for pariticular frame(DataDriven or Keword Driven)in Project? Thanks Balaji
suppose i opened 6browsers and i want re-open the 4browser what is code for this..pls help me..
What is the diffrence bettween QTP 9.0 and QTP 9.1?
Is text area check point supports for web applications?
Use of environment variables?
Am going to QTP testing......but i dont know coding languages like (c,c++,java,etc)and am not having interest in coding .............can i choose testing tools like qtp to learn and get a job in software......please reply me
How can you exit from an action?
Who is the best faculty for QTP in Hyderabad? Is it Mr. G.C.Reddy, some are referring his name?
hi, Can any body tell me whats the difference between the QTP and the Rational Robat ad the Silk Test and LOad Runner and are they used in any Company On the Major scale bcas I finnf Many comapny Using the Manual Testing Only Hence Askin the Question Hope I will get the Assitence .
Hi, i run scripts in one machine those r passed.when i run the scripts in client side those r failed.Give me such a scenario when ever u faced?