4

Given the path of a file (e.g. "C:\MyPicture.jpg"), how do I convert a binary file into a byte array?

I know I have a lot of .NET objects at my disposal, such as BinaryReader, FileStream, StreamReader, and others, but I'm not sure of the best method to take a binary file and convert it into byte[]. How might this be accomplished?

2 Answers 2

8

You're looking for File.ReadAllBytes(@"C:\MyPicture.jpg").

Sign up to request clarification or add additional context in comments.

Comments

6
byte[] bytes = File.ReadAllBytes("C:\\MyPicture.jpg");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.