How to convert binary file to byte array?

Given the file path (for example, "C: \ MyPicture.jpg"), how do I convert the binary to an array of bytes?

I know what I have in my possession a lot of .NET objects, such as BinaryReader, FileStream, StreamReaderand others, but I'm not sure what the best way to take a binary file and convert it to byte[]. How can I do that?

+3
source share
2 answers
+7
source
byte[] bytes = File.ReadAllBytes("C:\\MyPicture.jpg");
+5
source

Source: https://habr.com/ru/post/1736134/


All Articles