Click here to Skip to main content
15,850,675 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Guys,

I have the following code:

[code]
VB
Dim ofd As New OpenFileDialog
      ofd.ShowDialog()

      Dim br As New BinaryReader(File.Open(ofd.FileName, FileMode.Open))

      Dim chunk() As Byte

      chunk = br.ReadBytes(114)

[code]

I want to split the chosen file into chunks of 114 bytes, and then save each chunk. I've got the chunks into the array chunk(). I can't, however, figure out how to save each of these chunks to a file.

Any ideas?

Thanks in Advance,
Posted

IO functions usually come in pairs, so if there is a type BinaryReader[^] why don't you just look into MSDN and see if there is such a thing as a BinaryWriter[^]. I wouldn't react too surprised to find out that there was a method Write(Byte[])[^].

Regards,

—Manfred
 
Share this answer
 
v2
Comments
Wendelius 22-Aug-12 17:23pm    
Fair answer.
 
Share this answer
 
v2
Comments
Member 8230228 22-Aug-12 8:43am    
Thanks, I've seen those articles before but they don't do what I require. Which is to save each element of the byte() array to a separate file. Thanks though :)
Matt T Heffron 22-Aug-12 13:30pm    
This comment differs from your original description. This implies you want 114 files of 1 byte each!
In fact, your original code above only extracts the first 114 bytes from the file into the chunk() array, although the original description stated that chunk holds the collection of 114 byte pieces.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900