I want to handle the contents of a ZIP file, that was downloaded, only into memory (without using the hard disk!). packageStream
contains the bytes of the ZIP file.
MemoryStream packageStream = // Stream of downloaded ZIP file
var zipPackage = System.IO.Packaging.Package.Open(packageStream, FileMode.Open, System.IO.FileAccess.Read);
var parts = zipPackage.GetParts();
var rels = zipPackage.GetRelationships();
parts
and rels
do not contain any items.
Can anybody tell me what I'm doing wrong?
Is a MemoryStream
the wrong stream type?
Is the Package
class the wrong class for ZIP files in this scenario?
If you can tell me any alternatives, please no third party projects.
Thanks!
UPDATE
This answer in the duplicated question solved my problem (ZipArchive class). The accepted answer uses a third party project.