用VBS分割二进制文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Option Explicit

Function IIF(judgement, a, b)
  If judgement Then
    IIF = a
  Else
    IIF = b
  End If
End Function

Sub WriteBinaryFile(FileName, SaveMode)
  With CreateObject("ADODB.Stream")
    .Type = 1 : .Open: .Write Buf
    .SaveToFile FileName, SaveMode: .Close
  End With
End Sub

Sub SplitFile(SourceFile, DestinationFile, ChunkSize)
  Dim BufferSize
  BufferSize = 1024
  'ChunkSize 为 BufferSize 的倍数
  With CreateObject("ADODB.Stream")
    .Mode = 3: .Type = 1: .Open: .LoadFromFile SourceFile
    Dim lFileSize
    lFileSize = .Size
    Dim i
    i = 1
    Do While lFileSize >= ChunkSize * BufferSize
       Buf = .Read(ChunkSize * BufferSize)
       WriteBinaryFile DestinationFile & "." & CStr(i), IIf(objFSO.FileExists(DestinationFile & "." & CStr(i)), 2, 1)
       lFileSize = lFileSize - ChunkSize * BufferSize
       i = i + 1
    Loop
    If lFileSize > 0 Then
       Buf = .Read(lFileSize)
       WriteBinaryFile DestinationFile & "." & CStr(i), IIf(objFSO.FileExists(DestinationFile & "." & CStr(i)), 2, 1)
    End If
    .Close
  End With
  MsgBox "Finished!"
End Sub

Dim objFSO, Buf
Set objFSO = CreateObject("Scripting.FileSystemObject")
SplitFile "C:\test.rar", "C:\test", 512
Set objFSO = Nothing