从流中固定读取
读取固定长度
private static byte[] ReadBytes(Stream stream, int count)
{
var output = new byte[count];
var total = 0;
while (total < count)
{
var read = stream.Read(output, total, count - total);
if (read == 0)
{
throw new EndOfStreamException();
}
total += read;
}
return output;
}