Public Sub FileSplit(SourceFile As String, DestinationFile As String, ChunkSize As Long, Optional BufferSize As Long = 64# * 1024#, Optional ShowFinishMessage As Boolean)
'ChunkSize 为 BufferSize 的倍数
Dim FileBuffer() As Byte
Dim FileNumberS As Long
Dim FileNumberT As Long
FileNumberS = FreeFile
Open SourceFile For Binary Access Read As #FileNumberS
Dim lFileLen As Long
lFileLen = FileLen(SourceFile)
FileNumberT = FreeFile
Dim i As Long
Dim j As Long
ReDim FileBuffer(1 To (BufferSize)) As Byte
Open DestinationFile & "." & Format(i, "000") For Binary Access Write As #FileNumberT
Do While lFileLen >= BufferSize
Get #FileNumberS, , FileBuffer
If i = ChunkSize Then
i = 0
j = j + 1
Close #FileNumberT
FileNumberT = FreeFile
Open DestinationFile & "." & Format(j, "000") For Binary Access Write As #FileNumberT
End If
i = i + 1
Put #FileNumberT, , FileBuffer
lFileLen = lFileLen - BufferSize
Loop
If lFileLen > 0 Then
ReDim FileBuffer(1 To lFileLen) As Byte
Get #FileNumberS, , FileBuffer
Put #FileNumberT, , FileBuffer
End If
Close #FileNumberT
If ShowFinishMessage Then
MsgBox "Finished!"
End If
End Sub
Public Sub FileRestore(SourceFile As String, DestinationFile As String, Chunks As Long, Optional BufferSize As Long = 64# * 1024#, Optional ShowFinishMessage As Boolean)
Dim FileBuffer() As Byte
Dim FileNumberS As Long
Dim FileNumberT As Long
Dim i As Long
Dim lFileLen As Long
FileNumberT = FreeFile
Open DestinationFile For Binary Access Write As #FileNumberT
For i = 0 To Chunks - 1
FileNumberS = FreeFile
Open SourceFile & "." & Format(i, "000") For Binary Access Read As #FileNumberS
lFileLen = FileLen(SourceFile & "." & Format(i, "000"))
ReDim FileBuffer(1 To BufferSize) As Byte
Do While lFileLen >= BufferSize
Get #FileNumberS, , FileBuffer
Put #FileNumberT, , FileBuffer
lFileLen = lFileLen - BufferSize
Loop
If lFileLen > 0 Then
ReDim FileBuffer(1 To lFileLen) As Byte
Get #FileNumberS, , FileBuffer
Put #FileNumberT, , FileBuffer
End If
Close #FileNumberS
Next i
Close #FileNumberT
If ShowFinishMessage Then
MsgBox "Finished!"
End If
End Sub
这两个函数自己改改吧! 上面在案加上上条件 就应该可以了