public void WriteTo(Stream stream) { using (SubStream tmpstream = new SubStream(new MemoryStream())) { WriteTo(tmpstream); tmpstream.Seek(0, SeekOrigin.Begin); tmpstream.CopyTo(stream); } }