SharpDevelop Community

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

Exception while adding files to Zip64 archive

Last post 06-03-2008 3:09 AM by JohnReilly. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-25-2008 2:18 PM

    • Serial
    • Not Ranked
    • Joined on 02-25-2008
    • Posts 4

    Exception while adding files to Zip64 archive

    I use next code to create zip archive:

          using (FileStream inputStream = File.OpenRead(sourceFileName))
          {
              using (ZipOutputStream outputStream = new ZipOutputStream(File.Create(zipFileName)))
              {
                  outputStream.UseZip64 = UseZip64.Dynamic;
                  outputStream.SetLevel(compressionLevel);
                  ZipEntry entry = new ZipEntry(Path.GetFileName(sourceFileName));
                  entry.Size = inputStream.Length;
                  outputStream.PutNextEntry(entry);
                  byte[ dataBuffer = new byte[4096];
                  StreamUtils.Copy(inputStream, outputStream, dataBuffer);
                  outputStream.Finish();
              }
          }

    And next code to add file to existing archive:

          using (ZipFile zipFile = new ZipFile(zipFileName))
          {
              FileDataSource dataSource = new FileDataSource(sourceFileName);
              zipFile.UseZip64 = UseZip64.Dynamic;
              zipFile.BeginUpdate();
              zipFile.Add(dataSource, Path.GetFileName(sourceFileName));
              zipFile.CommitUpdate();
          }

    I create 5gb Zip64 archive using first source code and test it with zipFile.TestArchive(true) method. Than I append one small file to archive and test it again. Everything is alright.

    But when I try to append second file to this Zip64 archive I get an exception with message "End of extra data"!

    Please, can you help me to solve this problem? What is the reason of it? Note that there are no such problems when I work with simple Zip archives.

  • 02-25-2008 2:34 PM In reply to

    • Serial
    • Not Ranked
    • Joined on 02-25-2008
    • Posts 4

    Re: Exception while adding files to Zip64 archive

    ICSharpCode.SharpZipLib.Zip.ZipException : End of extra data

    --ZipException
    at ICSharpCode.SharpZipLib.Zip.ZipExtraData.ReadCheck(Int32 length)
    at ICSharpCode.SharpZipLib.Zip.ZipEntry.ProcessExtraData(Boolean localHeader)
    at ICSharpCode.SharpZipLib.Zip.ZipFile.ReadEntries()
    at ICSharpCode.SharpZipLib.Zip.ZipFile.RunUpdates()
    at ICSharpCode.SharpZipLib.Zip.ZipFile.CommitUpdate()

  • 02-25-2008 8:28 PM In reply to

    Re: Exception while adding files to Zip64 archive

    Hi,

    There is no way to tell whats going on without digging into the data and possibly the code as well.  What can be seen is that update processing has finished and re-reading the data is causing problems.

    So the question is what is wrong in the data and what is causing that to happen. 

    Not such an easy thing to dig into unfortunately.  However the file can be examined with other archivers like winzip etc to confirm that the file is corrupt.  Testing the archive can hopefully at least point to where things are going wrong as from your description there should be three entries but there is no indication as to which one is invalid.

    It would be very time intensive to try and explain what is going on internally and the fine points of zip archive structure so I wont try.  Do you think you have the background to dig into this yourself?

    Cheers, -jr- 

     

  • 02-27-2008 1:52 PM In reply to

    • Serial
    • Not Ranked
    • Joined on 02-25-2008
    • Posts 4

    Re: Exception while adding files to Zip64 archive

    I don't exactly understand what I have to do to dig into this :( 

     

    But there is some information that I can give you:

     

    step 1 - Zip64 archive was created (one entry)

     WinRAR says "No errors found during test operation".

      step1

      step1 info

     

    step 2 - first file was added to archive (two entries)

     WinRAR says "No errors found during test operation".

      step2

      step2 info

     

    step 3 - second file was added to archive (three entries) with exception "ICSharpCode.SharpZipLib.Zip.ZipException : End of extra data"

     WinRAR says "C:\...\test_file_archive.zip: Unexpected end of archive"  on open and "C:\...\test_file_archive.zip: The archive is corrupt" after test operation.

     WinRAR 3.71 shows that "test_file_source.txt" file size in archive has become incorrect and "test_file_source2.txt" file is hidden.

      step3

      step3 info

     But Total Commender 7.02a shows that "test_file_source.txt" file size in archive has become incorrect.

      step3 total commander

     

    Sorry for large post with images. I hope it will help somebody to solve this annoying problem.

  • 03-06-2008 10:33 AM In reply to

    • Serial
    • Not Ranked
    • Joined on 02-25-2008
    • Posts 4

    Re: Exception while adding files to Zip64 archive

     up

  • 06-03-2008 3:09 AM In reply to

    Re: Exception while adding files to Zip64 archive

    Hi,

    Sorry but I have very little access to the web right now.

    You could start with AEX a command line tool (http://www.geocities.com/licamft) which can help to identify were the data is invalid.

    From there it may revert to debugging to work out why/how this is happening.

    hth, -jr-

     

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