This project is read-only.

ZipEntry to ZipFile.

Feb 4, 2010 at 11:52 AM


I have a ZipFile which contains another zipfile as an entry in it. I am trying to access it in the following way:

using (ZipFile zf = ZipFile.Read(entryName))
                    ZipEntry zeData = null;
                    foreach (ZipEntry ze in zf.Entries)
                        string fName = System.IO.Path.GetFileName(ze.FileName);
                        if (!fName.Equals(""))
                            zeData = ze;
                    MemoryStream ms = new MemoryStream();
                    ZipFile zfData = ZipFile.Read(ms);


But it throws this exception:


{Ionic.Zip.BadReadException: Could not read block - no data!  (position 0x00000000)
   at Ionic.Zip.SharedUtilities._ReadFourBytes(Stream s, String message)
   at Ionic.Zip.SharedUtilities.ReadInt(Stream s)
   at Ionic.Zip.ZipFile.VerifyBeginningOfZipFile(Stream s)
   at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)
   at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)
   at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding)
   at Ionic.Zip.ZipFile.Read(Stream zipStream)
   at ModelBase.getStreamFor(String entryName) in C:\Inetpub\wwwroot\New Folder\BLL\Class1.cs:line 1186}


Please let me know if you have any suggestions.



Feb 4, 2010 at 12:00 PM

You must insert a line,

   ms.Seek(0, SeekOrigin.Begin);





Feb 4, 2010 at 12:30 PM

Thanks Cheeso.