You can use the Read method to specify a buffer and read block by block:
byte[] block = new byte[16];
int bytesRead = stream.Read(block, 0, block.Length);
In the above sample, bytesRead
contains the number of bytes that was read in the call to Read
. If there are no more bytes to read, bytesRead
will be 0.