Move zipStream.ToArray() outside of the zipArchive using.
The reason for your problem is that the stream is buffered. There’s a few ways to deal wtih it:
- You can set the stream’s
AutoFlushproperty totrue. - You can manually call
.Flush()on the stream.
Or, since it’s MemoryStream and you’re using .ToArray(), you can simply allow the stream to be Closed/Disposed first (which we’ve done by moving it outside the using).