Unpack nested zip from memory stream into another memory stream

0

Hi!

We try to uncompress a zip file from a streaming source like so:

[code lang='c#']public void Unzip (Stream stream)

{

    var zip = new ComponentPro.Compression.Zip();
    zip.Open(stream, false);
   
    // list all files
    foreach (var entry in zip.ListAll())
    {
        // if entry ends in zip
        if (entry.Name.EndsWith(".zip"))
            Unzip(entry.OpenRead(FileShare.Read));
    }
 
    zip.Close();
}
[/code]
 
However, reading the nested zip file using OpenRead() does not work (results in ComponentPro.IO.FileSystemNotSupportedException : The 'OpenRead' operation is not supported.) How to read a nested zip file from a stream?
 
We are currently evaluating your library and are thinking about buying it. This evaluation is timeboxed, so a quick answer would really help me to decide if we are going to buy your library or a library from another vendor.
 
Best regards,
D.R.
zip
edited 12/3/2017 2:00:40 AM
asked 10/2/2017 12:51:49 PM
add a comment

3 Answers

0

If you want to Unzip your nested file, you need to extract it to a temporary media or memory stream. We will investigate the feature to allow opening a nested file on the fly.

 
answered 11/16/2017 12:41:37 AM
add a comment
0

Hi!

Thank you for your answer.

ExtractFile() forces me to unzip the whole file at once. Is there a way to obtain a stream for a nested zip which is not automatically loading the whole nested zip into memory?

Best regards,

Dominik

 
answered 11/16/2017 12:41:37 AM
add a comment
0

Dear Sir,

You should extract that nested zip file to a memory stream like the code below:

[code lang='c#']public void Unzip (Stream stream)

 
{
 
    var zip = new ComponentPro.Compression.Zip();
 
    zip.Open(stream, false);
 
   
 
    // list all files
 
    foreach (var entry in zip.ListAll())
 
    {
 
        // if entry ends in zip
 
        if (entry.Name.EndsWith(".zip"))
{
            //Unzip(entry.OpenRead(FileShare.Read));
using (MemoryStream mem = new MemoryStream())
{
zip.ExtractFile(entry.FullName, mem);
Unzip(mem);
}
}
 
    }
 
 
 
    zip.Close();
 
}[/code]
 
Sorry for the code formatting. We are rolling out a new and modern website which will be available in 20-30 days.
 
answered 11/16/2017 12:41:37 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged zip or ask your own question.