Question

I'm getting an error when I use the SharpZipLib. I have code that looks like

FastZip compressor = new FastZip();
compressor.CreateZip(outputFileName, currentWorkingDirectory, true, "");

Which seems to be correct. However, I get a ZipException claiming that

size was 0, but I expected 54

I have no idea what that means. Anyone have any insight, or a link to an API document of some sort?

Was it helpful?

Solution

It turns out the issue was as follows. I was trying to make a .zip file of all the items in a given directory, and place that .zip file IN the directory. Apparently the way this library works, the .zip file is created, and then the directory is read in file-by-file, writing into the .zip file. The error occured when it tried to add the .zip file itself to the zip! It was probably denied access to the file or something at that point, resulting in the error above. Simple fix was to create the .ZIP file in a different directory.

OTHER TIPS

Here are links to their source code and a help file with API documentation.

I Had fixed similar issue by handling it inside ProgressHandler event handler and pass the ZIPEntry as Sender. As this is error condition so we should stop further processing of zip file e.ContinueRunning should be set as false

private void ProcessFileHandler(object sender, ProgressEventArgs e)
        {                    
                ZipEntry newEntry = sender as ZipEntry;
                if (newEntry != null)
                {
                    newEntry.Size = e.Processed;
                }
                e.ContinueRunning = keepRunning;
                return;
         }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top