Difference between Stream.CopyTo and MemoryStream.WriteTo

WriteTo() is resetting the read position to zero before copying the data – CopyTo() on the other hand will copy whatever data remains after the current position in the stream. That means if you did not reset the position yourself, no data will be read at all.

Most likely you just miss the following in your first version:

memoryStream.Position = 0;

Leave a Comment