I\'ve tried reading a JPG file using the StreamReader
class\' ReadToEnd()
method which returns a string.
For some reason though, when I wri
Strings are for text data. They're not for binary data - if you use them this way you will lose data (there are encodings you can use which won't lose data if you're lucky, but there are subtle issues which still make it a really bad idea.)
If you're actually dealing with a file, the easiest way of reading the whole thing is to call File.ReadAllBytes. If you have to deal with an arbitrary stream, have a look at "Creating a byte array from a stream".