Click here to Skip to main content
15,884,042 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
As anyone knows that computer working on binary (0s and 1s).
Every file/data have its binary source.
I want to Read/Access and edit binary of data/files like(.MP4 , .MP3, .ISO etc) in visual basic.
How can is do that?
Posted

1 solution

There are a huge number of ways: the simplest is:
VB
Dim data As Byte() = File.ReadAllBytes("D:\Temp\MyVideo.mp4")
data(0) = CByte(&Hff)
File.WriteAllBytes("D:\Temp\MyModifiedVideo.mp4", bytes)

But don't expect the file to work if you do exactly that! :laugh:
 
Share this answer
 
Comments
Valery Possoz 21-Jan-13 16:42pm    
For what ever reasons I think he want 0s and 1s... What about adding Dim bits As New BitArray(data)?
5 anyway :)
Alamgirable 22-Jan-13 7:57am    
Can you plz tell me how to call its binary data.
For example:After opening file using your above given method i want to make first binary value to equal 11 or 00.
Like this:
for example the first binary value of ("D:\Temp\MyVideo.mp4")is 1 or 0 i want to make it equal 11 or 00.
OriginalGriff 22-Jan-13 8:08am    
Soory - pleas etry to explain that a little better, perhaps with an example showing byte values.
If you want to replace a byte &H01 with a byte &H11 or &H03 that is easy - but your comment implies you might be trying to insert a single bit in the entire file, which is a lot harder! (And will wreck the file as far as it still being a valid video is concerned)
Alamgirable 22-Jan-13 9:12am    
Actually i want to edit the binary file and then compress it using algorithm.
Sorry for bad english.
OriginalGriff 22-Jan-13 9:21am    
You probably don't want to treat it as binary data - that will likely be far too slow - bytes are the "natural" size of most algorithmic compression as they are far, far easier to work with (or you might want to work with the hardware's true natural unit (32 or 64 bits) for speed.

Be aware that MP4 and MP3 and so forth are already compressed data formats, and you are unlikely to gain much in compression (unless you have a new, wonder algorithm, in which case sell it to someone big for serious amounts of money!)

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