I use this function to concat 2 or more byte arrays
private byte[] CombineByteArrays(params byte[][] arrays)
{
byte[] rv = new byte[arrays.Sum(a => a.Length)];
int offset = 0;
foreach (byte[] array in arrays)
{
System.Buffer.BlockCopy(array, 0, rv, offset, array.Length);
offset += array.Length;
}
return rv;
}
I the use the function like this
byte[] header, body, footer;
byte[] content = CombineByteArrays(header, body, footer);
networkStream1.Write(content, 0, content.Length);