This is a migrated thread and some comments may be shown as answers.

Exception when using ZipArchive

3 Answers 268 Views
ZipLibrary
This is a migrated thread and some comments may be shown as answers.
Marita
Top achievements
Rank 1
Marita asked on 04 Apr 2014, 06:56 AM
I have an application where I have been using the following code:

       using (ZipPackage zipPackage = ZipPackage.Open(stream, FileAccess.Read))
                    {
                        foreach (ZipPackageEntry file in zipPackage.ZipPackageEntries.ToList())
                        {
                            if (file.FileNameInZip.Equals("nsData.json"))
                            {
                                StreamReader streamReader = new StreamReader(file.OpenInputStream());
                                string jsonString = streamReader.ReadToEnd();
                            }
                       }
                 }

and it works as expected.

I have now tried to convert it to using ZipArchive instead, but I am having some problems.

I use the following code:

  using (ZipArchive archive = new ZipArchive(stream,ZipArchiveMode.Read, false, null))
                    {
                        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

                        ZipArchiveEntry entry = archive.GetEntry("nsData.json");
                        if (entry != null)
                        {
                            Stream entryStream = entry.Open();
                            StreamReader reader = new StreamReader(entryStream);
                            string content = reader.ReadToEnd();


                        }
            }

And when it comes to the last line it gives the following exception:

{Telerik.Windows.Zip.InvalidDataException: Invalid block length
   ved Telerik.Windows.Zip.DeflateDecompressor.DecodeBits()
   ved Telerik.Windows.Zip.DeflateDecompressor.DecodeUncompressedBlock(Boolean& endOfBlock)
   ved Telerik.Windows.Zip.DeflateDecompressor.CheckDecodeState()
   ved Telerik.Windows.Zip.DeflateDecompressor.Decode()
   ved Telerik.Windows.Zip.DeflateDecompressor.Inflate(Byte[] bytes, Int32 offset, Int32 length)
   ved Telerik.Windows.Zip.DeflateDecompressor.ProcessTransform(Boolean finalBlock)
   ved Telerik.Windows.Zip.DeflateTransformBase.TransformBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[] outputBuffer, Int32 outputOffset)
   ved Telerik.Windows.Zip.OperationStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   ved Telerik.Windows.Zip.CompressedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   ved System.IO.StreamReader.ReadBuffer()
   ved System.IO.StreamReader.ReadToEnd()
   ved NstPortalUCSL.ViewModel.ViewModelHandlers.DataSourceHandler.DataSouceHandler.<>c__DisplayClassb.<InitDataSources>b__8(Object sender, GetAllNstInstancesCompletedEventArgs args)
   ved NstPortalUCSL.NstPortalWsSvc.NstPortalWsClient.OnGetAllNstInstancesCompleted(Object state)}


I would be wery thankfull if you could explain to me what I am doing wrong.

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Apr 2014, 08:52 AM
Hi Marita,

Could you please clarify which version of Telerik UI for Silverlight you use? I suggest using the 2014 Q1 SP1 version as it contains important fixes in the Zip library.

Regards,
Andrey Murzov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Marita
Top achievements
Rank 1
answered on 04 Apr 2014, 10:39 AM
I use the latest version.
0
Andrey
Telerik team
answered on 04 Apr 2014, 12:17 PM
Hi Marita,

Unfortunately it is impossible to reproduce the problem at least without the zip file you use. Could you, please, provide us with this archive? By doing so we will be able to further investigate the reasons behind the issue.

Thank you for your cooperation.

Regards,
Andrey Murzov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ZipLibrary
Asked by
Marita
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Marita
Top achievements
Rank 1
Share this question
or