<p>I'm trying to create a Zip file from .Net that can be read from Java code.</p>

<p>I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying to uncompress it using the Java.Utils.Zip class in Java.</p>

<p>Problem seems to be in the wrong header written by SharpZipLib, I've also posted a question on the SharpDevelop forum but with no results (see <a href="http://community.sharpdevelop.net/forums/t/8272.aspx" rel="nofollow noreferrer">http://community.sharpdevelop.net/forums/t/8272.aspx</a> for info) but with no result.</p>

<p>Has someone a code sample of compressing a Zip file with .Net and de-compressing it with the Java.Utils.Zip class?</p>

<p>Regards
Massimo</p>

[{'answer_id': 71060, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 2, 'selected': False, 'text': '<p>Can\'t help with SharpZipLib, but you can try to create zip file using <a href="http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx" rel="nofollow noreferrer">ZipPackage</a> class <a href="http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx" rel="nofollow noreferrer">System.IO.Packaging</a> without using 3rd part libraries (requires .NET 3+).</p>\n'}, {'answer_id': 71072, 'author': 'Panos', 'author_id': 8049, 'author_profile': 'https://Stackoverflow.com/users/8049', 'pm_score': 4, 'selected': True, 'text': '<p>I have used <a href="http://www.codeplex.com/DotNetZip" rel="noreferrer">DotNetZip library</a> and it seems to work properly. Typical code:</p>\n\n<pre><code>using (ZipFile zipFile = new ZipFile())\n{\n  zipFile.AddDirectory(sourceFolderPath);\n  zipFile.Save(archiveFolderName);\n}\n</code></pre>\n'}, {'answer_id': 71890, 'author': 'Mike Dimmick', 'author_id': 6970, 'author_profile': 'https://Stackoverflow.com/users/6970', 'pm_score': 1, 'selected': False, 'text': '<p>To judge whether it\'s really a conformant ZIP file, see PKZIP\'s <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT" rel="nofollow noreferrer">.ZIP File Format Specification</a>.</p>\n\n<p>For what it\'s worth I have had no trouble using SharpZipLib to create ZIPs on a Windows Mobile device and open them with WinZip or Windows XP\'s built-in Compressed Folders feature, and also no trouble producing ZIPs on the desktop with SharpZipLib and processing them with my own ZIP extraction utility (basically a wrapper around zlib) on the mobile device.</p>\n'}, {'answer_id': 410383, 'author': 'Cheeso', 'author_id': 48082, 'author_profile': 'https://Stackoverflow.com/users/48082', 'pm_score': 1, 'selected': False, 'text': '<p>You don\'t wanna use the ZipPackage class in .NET - it isn\'t quite a standard zip model.  Well it is, but it presumes a particular structure in the file, with a manifest with a well-known name, and so on.  ZipPackage seems to have been optimized for Office docs and XPS docs.  </p>\n\n<p>A third-party library, like <a href="http://www.codeplex.com/DotNetZip" rel="nofollow noreferrer">http://www.codeplex.com/DotNetZip</a>, is probably a better bet if you are doing general-purpose ZIP files and want good interoperability. </p>\n\n<p>DotNetZip builds files that are very interoperable with just about everything, including Java\'s java.utils.zip.  But be careful using features that Java does not support, like ZIP64 or Unicode.  ZIP64 is useful only for very large archives, which Java does not support well at this time, I think.  Java supports Unicode in a particular way, so if you produce a Unicode-based ZIP file with DotNetZip, you just have to follow a few rules and it will work fine. </p>\n'}, {'answer_id': 487038, 'author': 'Igor Brejc', 'author_id': 55408, 'author_profile': 'https://Stackoverflow.com/users/55408', 'pm_score': 1, 'selected': False, 'text': '<p>I had a similar problem with unzipping SharpZipLib-zipped files on Linux. I think I solved it (well I works on Linux and Mac now, I tested it), check out my blog post: <a href="http://igorbrejc.net/development/c/sharpziplib-making-it-work-for-linuxmac" rel="nofollow noreferrer">http://igorbrejc.net/development/c/sharpziplib-making-it-work-for-linuxmac</a></p>\n'}, {'answer_id': 659397, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>I had the same problem creating zips with SharpZipLib (latest version) and extracting with java.utils.zip.</p>\n\n<p>Here is what fixed the problem for me. I had to force the exclusion of the zip64 usage:</p>\n\n<pre><code>ZipOutputStream s = new ZipOutputStream(File.Create(someZipFileName))\n\ns.UseZip64 = UseZip64.Off;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/71000', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11673/']