If I create a #Zip file from .Net I get errors when reading it from Java using the Java.Utils.Zip library.
Examining the file created via AEX tool it seems there is an error of mismatch between compressed and uncompressed size in the local file entry, while the central file header is correct:
<<Local file entry
Version 4.5
Flags 0000 Normal compression
Method Deflated
Date 9/2/2008 10:33:36 AM
Name 'Connectors.config'
Crc 68741CD4 Compressed size 128 Uncompressed size 140
Header mismatch - compressed size different
Header mismatch - uncompressed sizes are different
<<Central file header
Version made by 4.5 to extract 4.5
OS MSDOS + OS/2,NT (FAT+VFAT+NTFS)
Flags 0000 Normal compression
Method Deflated
Name length 17
Comment length 0
Internal attributes 00
External attributes 0000 MSDOS ------
Name 'Connectors.config'
Disk number start 0
Relative header offset 0
Crc 68741CD4 Compressed size 128 Uncompressed size 140
<<End of Central file header
Disk number 0
Start dir disk number 0
Entries this disk 1
Total entries 1
Central directory size 83
Offset 195
EOF
Done
I've tried various options assigning compressed and uncompressed size to the zipentry but it fails every time, only way I've found to make it work is to store the file (so no compression happens) and assigning Size and CompressedSize to be the same as file length, but this makes compressing files useless:
FileInfo
fileInfo = new FileInfo(FileFullPathName);using (FileStream fs = File.OpenRead(FileFullPathName))
{
byte[ buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(fileInfo.Name);entry.CompressionMethod = CompressionMethod.Stored;
entry.CompressedSize = fs.Length;
entry.Size = fs.Length;
entry.DateTime = DateTime.Now;
fs.Close();
Zipper.PutNextEntry(entry);
Zipper.Write(buffer, 0, buffer.Length);
Zipper.Flush();
Zipper.CloseEntry();
}
This is instead the code I'm using that fails, if I set any kind of property to Size or CompressedSize the AEX tool fails also on the Central File Header part :
FileInfo fileInfo = new FileInfo(FileFullPathName);using (FileStream fs = File.OpenRead(FileFullPathName))
{
byte[ buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(fileInfo.Name);entry.DateTime = DateTime.Now;
fs.Close();
Crc32 crc = new Crc32();
crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;
Zipper.PutNextEntry(entry);
Zipper.Write(buffer, 0, buffer.Length);
Zipper.Flush();
Zipper.CloseEntry();
}
Suggestions???
Regards
Massimo