Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Unexpected end of stream while reading a local header if you don’t read to the end of the file

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20355 |

    When I am using the ZipReader and as I am calling ReadItemData, if I don’t read to the end of the current file in the archive before calling ZipReader.ReadItemLocalHeader() I get the following exception:

    System.IO.EndOfStreamException: Unexpected end of stream while reading a local header from a zip file.

    at Xceed.Zip.ItemHeader.ReadLocalHeader(BinaryReader readerExtraHeaderList availableExtraHeadersref Int32 headerSize)
    at Xceed.Zip.ReaderWriter.ZipReader.DoReadItemLocalHeader(ReaderWriterItemInfo itemInfo)
    at Xceed.Zip.ReaderWriter.ZipReader.ReadItemLocalHeader()
    It would be nice if ReadItemLocalHeader() would move to the end of the current file for me if I am not already there.
     
    Just my two cents.

    Imported from legacy forums. Posted by Adam (had 1499 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Adam,

    ZipReader will not Seek() in the stream so that non-seekable streams, like network streams for example, work well.

    If you want to skip an item’s data, you can always dump that item’s data into a dummy stream. Like this:

       localHeader = zipReader.ReadItemLocalHeader();
       zipReader.ReadItemData( Stream.Null );

       localHeader = zipReader.ReadItemLocalHeader();
       // etc…

    ReadItemData() has flavors that accept a stream object. There, it will read the item’s data until it reached the end.

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 1321 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.