C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

too many length or distance symbols

rated by 0 users
This post has 4 Replies | 3 Followers

Not Ranked
Posts 3
BrustJ Posted: Wed, Dec 17 2008 11:03 AM

hi,

I've got following exception while trying to inflate a compressed stream.

C1.C1Zip.ZLib.ZStreamException: Error inflating: too many length or distance symbols
bei C1.C1Zip.C1ZStreamReader.a(Byte[] A_0, Int32 A_1, Int32 A_2)
bei C1.C1Zip.C1ZStreamReader.b(Byte[] A_0, Int32 A_1, Int32 A_2)
bei C1.C1Zip.C1ZStreamReader.Read(Byte[] buf, Int32 offset, Int32 count)
bei Test.Program.Main() in D:\Projekte\TODO\Test\Program.cs:Zeile 44.

I tried to extract the stream using  C1.C1Zip.dll and C1.C1Zip.2.dll, even with same result.

Is there a possibility to restore data anyway or to repair the stream? 

The stream was originally created using C1.C1Zip.dll.

 best reagards

Joe

Top 25 Contributor
Posts 356
C1_SteveB replied on Fri, Feb 13 2009 12:57 PM

Hello,

Thanks for using the C1 community forums.  I have code to help you extract, not sure what language you are using so I have both VB and C#.

      Visual Basic

Private Function GetDataFromZipFile(zipFileName As String, entryName As String) As Byte()

 

    ' Get the entry from the zip file.

    Dim zip As New C1ZipFile()

    zip.Open(zipFileName)

    Dim ze As C1ZipEntry = zip.Entries(entryName)

 

    ' Copy the entry data into a memory stream.

    Dim ms As New MemoryStream()

    Dim buf(1000) As Byte

    Dim s As Stream = ze.OpenReader()

    Try

        While True

            Dim read As Integer = s.Read(buf, 0, buf.Length)

            If read = 0 Then

                Exit While

            End If

            ms.Write(buf, 0, read)

        End While

    Finally

        s.Dispose()

    End Try

    s.Close()

 

    ' Return result.

    Return ms.ToArray()

End Function

 

C#

private byte[] GetDataFromZipFile(string zipFileName, string entryName)

{

 

    // Get the entry from the zip file.

    C1ZipFile zip = new C1ZipFile();

    zip.Open(zipFileName);

    C1ZipEntry ze = zip.Entries[entryName];

 

    // Copy the entry data into a memory stream.

    MemoryStream ms = new MemoryStream();

    byte[] buf = new byte[1000];

    using (Stream s = ze.OpenReader())

    {

        for (;;)

        {

            int read = s.Read(buf, 0, buf.Length);

            if (read == 0) break;

            ms.Write(buf, 0, read);

        }

    }

    // There's no need to call close because of the C# 'using'

    // statement above but in VB this would be necessary.

    //s.Close();

 

    // Return result.

    return ms.ToArray();

}

 

If you have any more questions, please let me know.

 

Thanks!

 

-Steve

Not Ranked
Posts 3
BrustJ replied on Wed, Feb 25 2009 9:19 AM

Hello Steve,

 

sorry for posting insufficient information.  My failure.

I try to extract a zipped stream using following (test)code:

FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);

MemoryStream ms = new MemoryStream();

C1ZStreamReader sr = null;

long pos = 0;

int total = 0;

byte[] buffer = new byte[1]; // just to see how much read

sr = new C1ZStreamReader(fs);

int read;

while ((read = sr.Read(buffer, 0, buffer.Length)) != 0)

{

pos = sr.Position;

ms.Write(buffer, 0, read);

total += buffer.Length;

}

ms.Flush();

ms.Close();

ms.Dispose();

Debug-Info when exception is thrown

sr.baseStream.Length == 3518703
sr.baseStream.Position == 1343488
sr.SizeUncompressed == 18590438

total == 18590437

Normally it works fine, but trying a special file it crashes on extracting.

Is there a way to repair a stream?

 

Joe

Top 10 Contributor
Posts 2,707

Hi Joe.

Can you send me (or post) the compressed file that is causing the problem? I'd like to take a look at it.

E-mail would be better if the file is big. The address is bernardoc at componentone dot com.

 

Thanks in advance

Not Ranked
Posts 3
BrustJ replied on Thu, Oct 22 2009 5:37 AM

Hi Bernado,

sorry for answering late.

I don't know if I've still got the file. I send it via mail ... if I find it ...

 

Joe

Page 1 of 1 (5 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.