用VB6.0实现将多个TXT文件合并成一个TXT文件
多个TXT的文件名都是以01,02,03...这些数字表示,但是每次要合并的文件数量和文件名都不一定一样,每个TXT文件的大小在10M以内。希望这方面的告诉能够不吝赐教,...
多个TXT的文件名都是以01,02,03...这些数字表示,但是每次要合并的文件数量和文件名都不一定一样,每个TXT文件的大小在10M以内。希望这方面的告诉能够不吝赐教,万分感谢!!!
展开
展开全部
Private Sub CommandButton1_Click()
Dim fRead, fWrite
Dim i%
Dim Buf() As Byte
Dim ReadFile(10) As String
Dim sPath As String
Dim sName As String
sPath = "D:\"
ReadFile(0) = "01.Txt": ReadFile(1) = "02.txt": ReadFile(2) = "03.txt"
fWrite = FreeFile
Open "D:\合并.txt" For Binary As fWrite
For i = 0 To 2
fRead = FreeFile
sName = sPath + ReadFile(i)
Open sName For Binary As fRead
ReDim Buf(FileLen(sName) + 1)
Get fRead, , Buf
Buf(UBound(Buf)) = 10
Buf(UBound(Buf) - 1) = 13
Put fWrite, , Buf
Close (fRead)
Next
Close (fWrite)
End Sub
Dim fRead, fWrite
Dim i%
Dim Buf() As Byte
Dim ReadFile(10) As String
Dim sPath As String
Dim sName As String
sPath = "D:\"
ReadFile(0) = "01.Txt": ReadFile(1) = "02.txt": ReadFile(2) = "03.txt"
fWrite = FreeFile
Open "D:\合并.txt" For Binary As fWrite
For i = 0 To 2
fRead = FreeFile
sName = sPath + ReadFile(i)
Open sName For Binary As fRead
ReDim Buf(FileLen(sName) + 1)
Get fRead, , Buf
Buf(UBound(Buf)) = 10
Buf(UBound(Buf) - 1) = 13
Put fWrite, , Buf
Close (fRead)
Next
Close (fWrite)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询