Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How do i convert System.Net.ConnectStream to a byte[] (array)

im trying to convert a stream (System.Net.ConnectStream) to a byte array. Any thoughts/examples on how this can be done?

like image 521
Mulaiko Avatar asked Sep 28 '12 19:09

Mulaiko


1 Answers

Stream sourceStream = ... // the ConnectStream
byte[] array;
using (var ms = new MemoryStream())
{
    sourceStream.CopyTo(ms);
    array = ms.ToArray();
}
like image 62
Thomas Levesque Avatar answered Oct 15 '22 05:10

Thomas Levesque