Creating a byte array from a stream

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2008-10-21T13:42:55Z Indexed on 2010/04/13 15:02 UTC
Read the original article Hit count: 329

Filed under:
|
|

What is the preffered method for creating a byte array from an input stream?

Here is my current solution with .NET 3.5.

Is it still a better idea to read and write chunks of the stream?

Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s)) {
	b = br.ReadBytes(s.Length);
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .net-3.5