Can anyone see any obvious holes in my logic here. Basically I need to break up a byte array into chunks of 10,000 before sending it out:
byte [] bytes = GetLargePieceOfData();
Stream stream = CreateAStream();
if (bytes.Length > 10000)
{
int pos = 0;
int chunkSize = 10000;
while (pos < bytes.Length)
{
if (pos + chunkSize > bytes.Length)
chunkSize = bytes.Length - pos;
stream.Write(bytes, pos, chunkSize);
pos += chunkSize;
}
}
else
{
stream.Write(bytes, 0, bytes.Length);
}