第1个回答 2013-11-14
给你一个方法吧。是读取整个文件的。
Public Function File_get_contents(path As String, Optional Unicode = "GB2312")
Dim arrBinary() As Byte
Open path For Binary As #1
ReDim arrBinary(LOF(1) - 1)
Get #1, , arrBinary()
Close #1
File_get_contents = BytesToBstr(arrBinary, Unicode)
End Function
替换方法,把文件读到字符串中,然后把字符串的内容 替换, 然后在写回到文件中。
例子:
str = File_get_contents("\1.txt") '你文件的路径
str = Replace(str, ")", chr(34) + ”,“ + chr(34) ) '替换 ) 为","
Open "\1.txt" For Output As #1
Print #1, str;
Close #1
'再写回去,,,需要引入上边的读取文件的方法哦