Odd error in SharpZipLib - size was x, but I expected y

I am getting an error when using SharpZipLib. I have some code that looks like

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

      

Which seems right. However, I am getting a ZipException claiming that

size was 0, but I expected 54

      

I have no idea what this means. Anyone have any understanding or reference to any API document?

+2


source to share


3 answers


It turns out that the problem was as follows. I was trying to make a .zip file of all items in a given directory and put that .zip file in the directory. Apparently the way this library works is to create a .zip file and then the directory is read file by file, writing to a .zip file. The error happened when he tried to add the ZIP file itself to the zip! It was probably denied access to the file or something at that location, resulting in the error above. A simple fix was to create a .ZIP file in a different directory.



+3


source


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



+1


source


I fixed a similar issue by handling it inside the ProgressHandler event handler and passing the ZIPEntry as the sender. Since this is an error condition, we must stop further processing the zip file. E.ContinueRunning must be set to false

private void ProcessFileHandler(object sender, ProgressEventArgs e)
        {                    
                ZipEntry newEntry = sender as ZipEntry;
                if (newEntry != null)
                {
                    newEntry.Size = e.Processed;
                }
                e.ContinueRunning = keepRunning;
                return;
         }

      

0


source







All Articles