MemoryStream to Byte Array (Byte[])

With the following code you can convert your MemoryStream to a Byte Array.

//create new Bite Array
byte[] biteArray = new byte[memoryStream.Length];

//Set pointer to the beginning of the stream
memoryStream.Position = 0;

//Read the entire stream
memoryStream.Read(biteArray, 0, (int)memoryStream.Length);

Leave a Reply

Your email address will not be published. Required fields are marked *