|
Function Replace_str(oldstr,newstr)
Set fso = CreateObject("scrīpting.FileSystemObject")
Set MyFilebak = fso.CreateTextFile("c:\testbak.txt", True)
MyFilebak.close
Set CreFile = fso.GetFile("c:\test.txt")
CreFile.Copy ("c:\testbak.txt")
Set MyFilebak=fso.OpenTextFile("c:\testbak.txt", 1, false)
Set theFile = fso.OpenTextFile("c:\test.txt", 2, True)
Do While MyFilebak.AtEndOfStream <> True
retstring = MyFilebak.ReadLine
If retstring=oldstr Then
theFile.WriteLine newstr
else
theFile.WriteLine retstring
End If
Loop
MyFilebak.close
Set DelFile = fso.GetFile("c:\testbak.txt")
DelFile.Delete
theFile.Close
ReadEntireFile = retstring
End Function
Call Replace_str("#orcal=true","orcal=true")
Call Replace_str("MySQL=true","#MySQL=true")
在QTP里直接运行上面代码,出现
ActiveX部件不能创建对象:'scripting.filesystemobject' |
|