Category: Exceptions

Cannot close stream until all bytes are written – C#

This error is raised when the position of stream or memory stream object is set at the end of stream. To resolve the issue either you can set the position to “o” as shown below.

If this doesn’t work, you can re-create the memory stream as shown below