The Compressed (zipped) Folder is invalid or corrupted with SharpZipLib

I have generated Zip File using SharpZipLib. But when i try to access it using Windows XP extraction tool it shos following error:  Compressed (zipped) Folder is invalid or corrupted and it worked fine with 7zip. So, i did googling and found one nice solution from this link : http://blog.tylerholmes.com/2008/12/windows-xp-unzip-errors-with.html
Solution is — extracted from the above blog only.
[sourcecode language=”csharp”]

ZipEntry entry = new ZipEntry(Path.GetFileName(sourceFilePath));
entry.DateTime = DateTime.Now;
/* By specifying a size, SharpZipLib will turn on/off UseZip64 based on the file sizes. If Zip64 is ON
* some legacy zip utilities (ie. Windows XP) who can’t read Zip64 will be unable to unpack the archive.
* If Zip64 is OFF, zip archives will be unable to support files larger than 4GB. */
entry.Size = new FileInfo(sourceFilePath).Length;
zipStream.PutNextEntry(entry);

[/sourcecode]
If it works say thanks to Tyler Holmes — Above Blog author, for such a nice article!
Happy zipping!

5 Comments

  • It didn’t work, I tried everything. This looks like a bug

    • Can you pls post some code? Might be I can help you out in solving an issue.
      Happy Coding 🙂
      Thanks,
      Kiran

  • which software you arev using to unzip compressed folder. I had same error i was using 7zip tp extract files than i tried Winrar to unzip compressed folder and i successfully extracted files.
    Hope this will help.

Comments are closed.