private static byte[] CombineArrays(byte[] source, byte[] destination)
{
int destPointer = 0;
//if we are starting with nothing in our destination, lets new it up with the same size as our source length
if (destination == null)
{
destination = new byte[source.Length];
}
else
{
//destination already has data
destPointer = destination.Length;
//lets create a new buffer, that can handle both sets of data
var newDest = new byte[source.Length + destination.Length];
//copy destination into the first bytes of the newly allocated array
destination.CopyTo(newDest, 0);
//set destination to our larger buffer
destination = newDest;
}
//push the source bits into the trailing slots of our final destination
source.CopyTo(destination, destPointer);
return destination;
}