I have a memory stream that contains a zip file in byte[] format .
Is there any way I can unzip this memory stream, without any need of writing the file to disk ?
I've just had a similar issue and the answer I found which I think seems to be fairly elegant is to use #ZipLib (available using nuget) and do the following:
private byte[] GetUncompressedPayload(byte[] data)
{
using (var outputStream = new MemoryStream())
using (var inputStream = new MemoryStream(data))
{
using (var zipInputStream = new ZipInputStream(inputStream))
{
zipInputStream.GetNextEntry();
zipInputStream.CopyTo(outputStream);
}
return outputStream.ToArray();
}
}
This seems to have worked a treat. Hope this helps.