I would like to know how to convert a stream to a byte.
I find this code, but in my case it does not work:
var memoryStream = new MemoryStream();
paramFile.CopyTo(memoryStream);
byte[] myBynary = memoryStream.ToArray();
myBinary = memoryStream.ToArray();
But in my case, in the line paramFile.CopyTo(memoryStream) it happens nothing, no exception, the application still works, but the code not continue with the next line.
Thanks.
If you are reading a file just use the File.ReadAllBytes Method:
Also, there is no need to CopyTo a MemoryStream just to get a byte array as long as your sourceStream supports the Length property: