SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Wrong central directory signature

Last post 08-24-2015 6:18 PM by bobulus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-15-2015 4:13 PM

    Wrong central directory signature

    I'm getting an exception unzipping a file ("Wrong Central Directory signature") from the ZipFile class. The exception occurs in the function ReadEntries. I'm constructing the class using a stream...

    FileStream fs = File.OpenRead(Program.CMSZip);
    ZipFile zf = new ZipFile(fs);

    The code in ReadEntries where it bombs follows:

    for (ulong i = 0; i < entriesForThisDisk; i++) {
                    if (ReadLEUint() != ZipConstants.CentralHeaderSignature) {
                        throw new ZipException("Wrong Central Directory signature");
                    }

    ReadLEUnit is returning 5033012. The value of ZipConstants.CentralHeaderSignature is 3363928. They don't match and hence the exception is thrown.

    I've been using this code to unzip a file we download monthly for quite some time (2 years?) without a problem. And 7Zip unzips the file without a problem, so I have no idea what is causing the issue. The file is large (547,683KB), but these files are always large and the zip library hasn't had problems with them in the past.

    Anyone have any clues as to what might be happening?

    Thanks in advance,

    Bob

     

     

     

     

     

     

     

     

  • 07-16-2015 7:14 AM In reply to

    Re: Wrong central directory signature

    Hi Bob,

    The code expects the Central Directory to be quite close to the end of the file. I recall an issue some years ago where there was extra data at the end of someone's file, that threw it off. Other utilities such as 7-Zip might be more forgiving. Not sure if this is the explanation here; just the first thing that comes to mind.

    Can you open it with WinZip, any version from 9 onwards, then click Properties and then Details. The output does provide a useful integrity check. Look for any warnings in there, in the first instance.

    Let us know how that goes.

    Thanks, Dave

  • 07-16-2015 2:47 PM In reply to

    Re: Wrong central directory signature

    Hi Dave...

    Just so you know......I first downloaded the eval version 19.5 of WinZip and it doesn't seem to have the same facility to get the properties of the zip (unless that's only for registered users?).

    Anyways, they had legacy versions on the site, I downloaded WinZip 10, and got this from the Properties/Details dialog...

    Testing ...

    Current Location part 1 offset 560826846

    Archive: C:\MeaningfulUseWizard\ProviderToExcelWizard\bin\Debug\NPPES_Data_Dissemination_July_2015.zip 560826868 bytes 2015-07-15 08:49:48

    End central directory record PK0506 (4+18)

    ==========================================

    current location of end-of-central-dir record: 560826846 (0x216d89de) bytes

    expected location of end-of-central-dir record: 560826770 (0x216d8992) bytes

    based on the size of the central directory of

    462 and its relative offset of 560826308 bytes

    part number of this part (0000): 1

    part number of start of central dir (0000): 1

    number of entries in central dir in this part: 4

    total number of entries in central dir: 4

    size of central dir: 462 (0x000001ce) bytes

    relative offset of central dir: 560826308 (0x216d87c4) bytes

    zipfile comment length: 0

    Current Location part 1 offset 560826308

    Central directory entry PK0102 (4+42): #1

    ======================================

    part number in which file begins (0000): 1

    relative offset of local header: 0 (0x00000000) bytes

    version made by operating system (03): Unix

    version made by zip software (30): 3.0

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (45): 4.5

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000530): 2015-07-14 00:41:32

    32-bit CRC value: 0xb1c8b2cb

    compressed size: 560159888 bytes

    uncompressed size: 4294967295 bytes

    length of filename: 29 characters

    length of extra field: 36 bytes

    length of file comment: 0 characters

    internal file attributes: 0x0001

    apparent file type: text

    external file attributes: 0x81800000

    Unix file attributes (100600 octal): -rw-------

    MS-DOS file attributes (0x00): none

    Current Location part 1 offset 560826354

    filename:npidata_20050523-20150712.csv

    Current Location part 1 offset 560826383

    extra field 0x5455 (universal time), 4 header and 5 data bytes:

    03 fc 92 a4 55 ....U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    extra field 0x0001 (ZIP64 Tag), 4 header and 8 data bytes:

    a6 01 bf 4e 01 00 00 00 ...N....

    ZIP64 Tag Value(s):

    Value #1: 5616107942

    Current Location part 1 offset 560826419

    Central directory entry PK0102 (4+42): #2

    ======================================

    part number in which file begins (0000): 1

    relative offset of local header: 560159995 (0x21635cfb) bytes

    version made by operating system (03): Unix

    version made by zip software (30): 3.0

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000530): 2015-07-14 00:41:32

    32-bit CRC value: 0xd6b99936

    compressed size: 1378 bytes

    uncompressed size: 12249 bytes

    length of filename: 39 characters

    length of extra field: 24 bytes

    length of file comment: 0 characters

    internal file attributes: 0x0001

    apparent file type: text

    external file attributes: 0x81800000

    Unix file attributes (100600 octal): -rw-------

    MS-DOS file attributes (0x00): none

    Current Location part 1 offset 560826465

    filename:npidata_20050523-20150712FileHeader.csv

    Current Location part 1 offset 560826504

    extra field 0x5455 (universal time), 4 header and 5 data bytes:

    03 fc 92 a4 55 ....U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 560826528

    Central directory entry PK0102 (4+42): #3

    ======================================

    part number in which file begins (0000): 1

    relative offset of local header: 560161470 (0x216362be) bytes

    version made by operating system (03): Unix

    version made by zip software (30): 3.0

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000531): 2015-07-14 00:41:34

    32-bit CRC value: 0xa840294e

    compressed size: 261276 bytes

    uncompressed size: 344918 bytes

    length of filename: 54 characters

    length of extra field: 24 bytes

    length of file comment: 0 characters

    internal file attributes: 0x0000

    apparent file type: binary

    external file attributes: 0x81c00000

    Unix file attributes (100700 octal): -rwx------

    MS-DOS file attributes (0x00): none

    Current Location part 1 offset 560826574

    filename:NPPES Data Dissemination_Public File - Code Values.pdf

    Current Location part 1 offset 560826628

    extra field 0x5455 (universal time), 4 header and 5 data bytes:

    03 fd 92 a4 55 ....U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 560826652

    Central directory entry PK0102 (4+42): #4

    ======================================

    part number in which file begins (0000): 1

    relative offset of local header: 560422858 (0x21675fca) bytes

    version made by operating system (03): Unix

    version made by zip software (30): 3.0

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000531): 2015-07-14 00:41:34

    32-bit CRC value: 0x300522d1

    compressed size: 403344 bytes

    uncompressed size: 520252 bytes

    length of filename: 48 characters

    length of extra field: 24 bytes

    length of file comment: 0 characters

    internal file attributes: 0x0000

    apparent file type: binary

    external file attributes: 0x81c00000

    Unix file attributes (100700 octal): -rwx------

    MS-DOS file attributes (0x00): none

    Current Location part 1 offset 560826698

    filename:NPPES Data Dissemination_Public File- Readme.pdf

    Current Location part 1 offset 560826746

    extra field 0x5455 (universal time), 4 header and 5 data bytes:

    03 fd 92 a4 55 ....U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 0

    Local directory entry PK0304 (4+26): #1

    ------------------------------------

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (45): 4.5

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000530): 2015-07-14 00:41:32

    32-bit CRC value: 0xb1c8b2cb

    compressed size: 4294967295 bytes

    uncompressed size: 4294967295 bytes

    length of filename: 29 characters

    length of extra field: 48 bytes

    Current Location part 1 offset 30

    filename:npidata_20050523-20150712.csv

    Current Location part 1 offset 59

    extra field 0x5455 (universal time), 4 header and 9 data bytes:

    03 fc 92 a4 55 94 92 a4 55 ....U...U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    extra field 0x0001 (ZIP64 Tag), 4 header and 16 data bytes:

    a6 01 bf 4e 01 00 00 00 90 5c 63 21 00 00 00 00 ...N.....\c!....

    ZIP64 Tag Value(s):

    Value #1: 5616107942

    Value #2: 560159888

    Current Location part 1 offset 107

    testing: npidata_20050523-20150712.csv OK

    Current Location part 1 offset 560159995

    Local directory entry PK0304 (4+26): #2

    ------------------------------------

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000530): 2015-07-14 00:41:32

    32-bit CRC value: 0xd6b99936

    compressed size: 1378 bytes

    uncompressed size: 12249 bytes

    length of filename: 39 characters

    length of extra field: 28 bytes

    Current Location part 1 offset 560160025

    filename:npidata_20050523-20150712FileHeader.csv

    Current Location part 1 offset 560160064

    extra field 0x5455 (universal time), 4 header and 9 data bytes:

    03 fc 92 a4 55 fc 92 a4 55 ....U...U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 560160092

    testing: npidata_20050523-20150712FileHeader.csv OK

    Current Location part 1 offset 560161470

    Local directory entry PK0304 (4+26): #3

    ------------------------------------

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000531): 2015-07-14 00:41:34

    32-bit CRC value: 0xa840294e

    compressed size: 261276 bytes

    uncompressed size: 344918 bytes

    length of filename: 54 characters

    length of extra field: 28 bytes

    Current Location part 1 offset 560161500

    filename:NPPES Data Dissemination_Public File - Code Values.pdf

    Current Location part 1 offset 560161554

    extra field 0x5455 (universal time), 4 header and 9 data bytes:

    03 fd 92 a4 55 fc 92 a4 55 ....U...U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 560161582

    testing: NPPES Data Dissemination_Public File - Code Values.pdf OK

    Current Location part 1 offset 560422858

    Local directory entry PK0304 (4+26): #4

    ------------------------------------

    operat. system version needed to extract (00): MS-DOS, OS/2, NT FAT

    unzip software version needed to extract (20): 2.0

    general purpose bit flag (0x0000) (bit 15..0): 0000.0000 0000.0000

    file security status (bit 0): not encrypted

    extended local header (bit 3): no

    compression method (08): deflated

    compression sub-type (deflation): normal

    file last modified on (0x000046ee 0x00000531): 2015-07-14 00:41:34

    32-bit CRC value: 0x300522d1

    compressed size: 403344 bytes

    uncompressed size: 520252 bytes

    length of filename: 48 characters

    length of extra field: 28 bytes

    Current Location part 1 offset 560422888

    filename:NPPES Data Dissemination_Public File- Readme.pdf

    Current Location part 1 offset 560422936

    extra field 0x5455 (universal time), 4 header and 9 data bytes:

    03 fd 92 a4 55 fd 92 a4 55 ....U...U

    extra field 0x7875 (unknown), 4 header and 11 data bytes:

    01 04 c0 01 00 00 04 03 04 00 00 ...........

    Current Location part 1 offset 560422964

    testing: NPPES Data Dissemination_Public File- Readme.pdf OK

    No errors detected in compressed data of C:\MeaningfulUseWizard\ProviderToExcelWizard\bin\Debug\NPPES_Data_Dissemination_July_2015.zip.

    Thanks,

    Bob

     

  • 08-24-2015 6:18 PM In reply to

    Re: Wrong central directory signature

    Hi Dave....

    I haven't heard anything back on this. My last response included the output from WinZip. I didn't see anything in there that jumped out at me, but not exactly sure what I'm looking at in the 1st place.

    In any case, the unzipping code I use runs in a monthly job.I left it as-is after the failure last month hoping it was just a one-time glitch in that month's zip file. Unfortunately this month I got the same error.

    To work around this on my end, I just had my code shell out to 7zip to to the unzipping, but if possible would rather use the sharp-develop libs and do this inside my code.

    Any clues? I assume this is the same error as last month and you should be able to use my last response as a guide to the zip file I'm dealing with.

    Thanks,

    Bob

     

     

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.