Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i could convert it to binary but i couldn't vice versa it
this is my code


byte[] bytes = System.IO.File.ReadAllBytes(sellected-file);
textBox2.Text = string.Join(" ", bytes.Select(b => Convert.ToString(b,2).ToUpper()));

thanks in advance

What I have tried:

byte[] bytes = System.IO.File.ReadAllBytes(sellected-file);
textBox2.Text = string.Join(" ", bytes.Select(b => Convert.ToString(b,2).ToUpper()));
Posted
Updated 4-Aug-20 22:18pm
Comments
Richard MacCutchan 13-Aug-16 12:46pm    
A video file is already binary, just like any other file.
Member 12431965 13-Aug-16 12:51pm    
if you change extension of file to *.bin you could see 1s and 0s ?
no you see a lot of character
Richard MacCutchan 13-Aug-16 13:02pm    
I guess you do not understand what a file is.

You can change the extension to anything you like, but it will not affect the content of the file. It just lets Windows Explorer (and other apps) think that the file is formatted in a particular way. But the fact remains that all files are basically just a stream of bytes; it is how you interpret those bytes that makes them appear in a particular way.
Member 12431965 13-Aug-16 13:06pm    
i know all data in computer is 1s and 0s but if i have a binary code how to convert it to video file?
Richard MacCutchan 13-Aug-16 14:28pm    
The question makes no sense. You cannot just take some binary data and magically make it into a video. You need to understand the structure of video data and how all the pieces are used in making vision and sound.

What you are doing is completely wrong: if you want to display a video file as hexadecimal bytes, then you can do it like this:
C#
byte[] bytes = System.IO.File.ReadAllBytes(sellected-file);
textBox2.Text = BitConverter.ToString(bytes);

But... you do realise that video files tend towards a huge number of bytes, and that converting them to a hex string will treble the amount of space needed? This will not be a fast process anything other than trivial video files...
 
Share this answer
 
Quote:
How to convert video to binary and vice versa C#
This is no sense, because video files are binary, there is no conversion to do.
Quote:
if you change extension of file to *.bin you could see 1s and 0s ?
no you see a lot of character
No sense, the file extension is just here to help windows choose the right tool when you want to open a file.
Quote:
a binary code how to convert it to video file?
You don't. Nothing can transform some binary data to video if it is not video all ready.

When I want to see the inside of a video file, I open it with a programmer's editor, and say the editor to display it as hexadecimal. I use UltraEdit.
UltraEdit: the text editor trusted by millions[^]

Nota: when you open a file, you can tell which tool you want to use. This is windows knowledge.
 
Share this answer
 

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