public void FinishArray(Type t) { totalPaddingAdded += writeStream.AdvanceTo8ByteBoundary(); //now need to overwrite the dimensions with the correct value writeStream.Seek((int)dimensionsStartPosition, SeekOrigin.Begin); //silly matlab format dimension definition wasn't made for realtime streaming... without the following, strings would need to be transposed in matlab to be readable if (t.Equals(typeof(char))) { writeStream.Write(dimensions[0]); writeStream.Write(dimensions[1]); } else { writeStream.Write(dimensions[1]); writeStream.Write(dimensions[0]); } //and the full size of the array writeStream.Seek((int)totalLengthStartPosition, SeekOrigin.Begin); writeStream.Write((int)(headerLength + dataLength + totalPaddingAdded)); //and the size of the data only writeStream.Seek((int)dataLengthStartPosition, SeekOrigin.Begin); writeStream.Write((int)dataLength); //set pointer back to end of stream writeStream.Seek(0, SeekOrigin.End); //indicate this array has finished, so the writeStream can be used by others this.hasFinished = true; }