0

Am implementing a feature in an ASP.NET web application in the office to let people upload zip files in which there is an xml file to import into a database.

The problem is, I get this error when using System.IO.Compression.ZipFile:

"Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory."

and when I use System.IO.Compression.DeflateStream, I get this error:

"Block length does not match with its complement."

Does not Windows zip use the same libraries? Are the zip formats/algorithms different from .Net to Windows zip?

and if anyone can suggest a solution I would be thankful.

Rez.Net
  • 1,354
  • 2
  • 19
  • 28
  • Have you tried ionic.zip? – CodesInChaos Apr 30 '15 at 06:47
  • The directory in the .zip archive is corrupted. It is located at the end of the file, always a good place to cause trouble when you don't upload the file correctly. – Hans Passant Apr 30 '15 at 10:20
  • @CodesInChaos just downloaded it, am going to give it a go. – Rez.Net May 01 '15 at 00:18
  • @HansPassant the error indicates that but it happens every time I zip with windows zip, so there must be due to different expectation of file format by .net compression library. Sounds illogical and that is what confuses me. Am going to use other libraries but I doubt I am the only one who expects .Net libraries to be able to open up a file zipped with Windows zip. – Rez.Net May 01 '15 at 00:20

2 Answers2

0

This may be yet another bug in the .NET implementations for deflate, zip, etc. support. You should try DotNetZip instead.

Community
  • 1
  • 1
Mark Adler
  • 101,978
  • 13
  • 118
  • 158
0

I found the issue, it seems there was nothing wrong with .net libraries to unzip the file, the problem was with the way the file written to disk after being uploaded to my asp.net application, a problem with encoding was in place, since I wrote the exact bytes into disk I was able to unzip it with .Net libraries.

Thanks for everyone's contribution.

Rez.Net
  • 1,354
  • 2
  • 19
  • 28