Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET RealTime Zip for .NET throws ArgumentOutOfRangeException for offset parameter

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

    Its seems every time I have a large file (i.e. 9mb+) the while loop (on the last loop) will always through an argumentoutofrangeexception.  Am I doing something wrong, or is this a bug with the component.   Here is my code sample below:

     

             // get original stream (assume it compressed already)and
    set some properties

                using
    (System.IO.MemoryStream compressedStream = new
    System.IO.MemoryStream(context.Data.InternalBytes))

                {

                   
    compressedStream.Seek(0, System.IO.SeekOrigin.Begin);

     

                    //
    set up a new stream to get the decompressed data

                   
    using (System.IO.MemoryStream decompressedStream = new
    System.IO.MemoryStream())

                    {

                       
    // load the zip reader with original stream

                       
    using (Xceed.Zip.ReaderWriter.ZipReader zipReader = new
    Xceed.Zip.ReaderWriter.ZipReader(compressedStream, false))

                       
    {

                           
    if (!string.IsNullOrEmpty(password)) zipReader.EncryptionPassword =
    password;

     

                           
    //Read the item’s local header. this will also determine if its a zip

                           
    try

                           
    {

                                itemHeader =
    zipReader.ReadItemLocalHeader();

                               processAsZip = itemHeader != null;

                           
    }

                           
    catch (Xceed.Zip.ReaderWriter.ZipReaderException zipEx)

                           
    {

                                if
    (zipEx.Message.StartsWith(“No zip header signature found”,
    StringComparison.InvariantCulture))

                                {

                                    //don’t do
    anything…just ignore because its not a zipped file

                                }

                                else

                                    throw;

                           
    }

     

                           
    if (processAsZip)

                           
    {

                                int readBytesCount
    = 0;

                                byte[] readBytes = new byte[8192];

     

                                // Read data from
    and write it to decompressedStream

                                while
    ((readBytesCount = zipReader.ReadItemData(readBytes, 0, readBytes.Length)) >
    0)

                                {

                                   
    decompressedStream.Write(readBytes, 0, readBytesCount);

                                }

                               
    decompressedStream.Seek(0, System.IO.SeekOrigin.Begin);

                           
    }

                       
    }

                       
    decompressedStream.Close();

                    }

                   
    compressedStream.Close();

                }

     

    Imported from legacy forums. Posted by Martin (had 1023 views)

    User (Old forums)
    Member
    Post count: 23064

    figured it out.  Goofy error on my part with the original bytes

    Imported from legacy forums. Posted by Martin (had 799 views)

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