|
用楼上的办法是可以的,不过感觉笨了,有没有别的办法呢?
方法如下:
- Function Replace_str(oldstr,newstr)
- Set fso = CreateObject("Scripting.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")
复制代码 |
|