Help in creating .zip files from .NET and reading them from Java

I am trying to create a zip file from a .Net that can be read from Java code.

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

The problem seems to be in the wrong title written by SharpZipLib, I also posted a question on the SharpDevelop forum, but without results (see http://community.sharpdevelop.net/forums/t/8272.aspx for information), but without result.

Does anyone have an example of code to compress a Zip file with .Net and compress it using the Java.Utils.Zip class?

Relations Massimo

+4
source share
6 answers

I used the DotNetZip library and it seems to work correctly. Typical code:

using (ZipFile zipFile = new ZipFile()) { zipFile.AddDirectory(sourceFolderPath); zipFile.Save(archiveFolderName); } 
+8
source

I had the same problem as creating zips with SharpZipLib (latest version) and extracting using java.utils.zip.

This is what posed the problem to me. I had to forcibly exclude the use of zip64:

 ZipOutputStream s = new ZipOutputStream(File.Create(someZipFileName)) s.UseZip64 = UseZip64.Off; 
+3
source

It is impossible to help with SharpZipLib, but you can try to create a zip file using the ZipPackage class System.IO.Packaging without using the libraries of the third part (.NET 3+ required).

+2
source

You do not want to use the ZipPackage class in .NET - this is not a very standard zip model. Well, but that involves a certain structure in the file, with a manifest with a known name, etc. ZipPackage seems to be optimized for Office documents and XPS documents.

A third-party library, for example http://www.codeplex.com/DotNetZip , is probably better if you make general purpose ZIP files and want good compatibility.

DotNetZip creates files that are very compatible with almost everyone, including Java java.utils.zip. But be careful when using features that Java does not support, such as ZIP64 or Unicode. ZIP64 is only useful for very large archives that Java does not support well at this time, I think. Java supports Unicode in a certain way, so if you create a Unicode based ZIP file with DotNetZip, you just need to follow a few rules and it will work fine.

+2
source

To judge if this is a compatible ZIP file, see PKZIP . ZIP file format specification .

Why I didnโ€™t have problems using SharpZipLib to create ZIP files on a Windows Mobile device and open them using the built-in Compressed Folders from WinZip or Windows XP, and also without problems creating ZIP files on my desktop using SharpZipLib and processing them with my own utility for extracting zip (mostly a shell around zlib) on a mobile device.

+1
source

I had a similar problem with unpacking SharpZipLib-zipped files on Linux. I think I decided (well, I'm working on Linux and Mac right now, I tested it), check out my blog post: http://igorbrejc.net/development/c/sharpziplib-making-it-work-for- linuxmac

+1
source

Source: https://habr.com/ru/post/1276741/


All Articles