我有一个非常大的二进制文件250 gigs工作将此文件拆分为较小的文件,从某个字节标题开始,直到达到新的标题或文件结尾我希望将此部分存储为单独的新文件对于这样的每个案例。
从第一次出现到文件结束的所有数据都将作为单独的文件存储。
Sub hexDumpFile(fil As String)
Using reader As New BinaryReader(File.Open(fil, FileMode.Open))
' Loop through length of file.
Dim pos As Integer = 0
Dim length As Long = reader.BaseStream.Length
'looking up for 00 00 01 BA 44 00 04 00 04
Dim header(9) As Byte
Dim buff(18) As Byte
header = {&H0, &H0, &H1, &HBA, &H44, &H0, &H4, &H0, &H4}
buff.Initialize()
Dim i As Integer
While pos < length - buff.Length
'--- Read the integer.
buff.Initialize()
buff = reader.ReadBytes(buff.length)
Console.Write(Hex(pos) & ":")
' Write to screen.
Try
For i = 0 To buff.Length
Console.Write(Hex(buff(i))) hex value
Console.Write(" ") ' space
Next
Console.WriteLine("") ' line break
Catch EX As Exception
Console.WriteLine(EX.Source.ToString)
Console.WriteLine(EX.Message)
End Try
' Add length of integer in bytes to position.
pos += 1
End While
End Using
End Sub