Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2092
Cannot create a ZipFile from a string
posted

I'm using the Infragistics.Compression library to create and extract zip files. I can create a zip file fine and save it to a memorystream but I need to go further and store the zip file as a string. I can create a string from the memorystream using StreamReader and that works fine but when I try to create a ZipFile object from the string it fails every time. First I convert the string to a byte array and then give that to the ZipFile constructor as a parameter. The exception I get is:

{Infragistics.Compression.BadReadException:   ZipEntry::ReadDirEntry(): Bad signature (0x00000000) at position 0x02BDBFEB
at Infragistics.Compression.ZipEntry.ReadDirEntry(ZipFile zf)
at Infragistics.Compression.ZipFile.ReadCentralDirectory(ZipFile zf)
at Infragistics.Compression.ZipFile.ReadIntoInstance(ZipFile zf)}

Any ideas how I can store the and then retrieve a zip file to and from a string?

Parents
  • 2092
    posted

    Some additional information. If I go for a byte array directly from the stream I saved the ZipFile I get a bytearray of length 818 and if I use that byte array to create back a ZipFile, the operation succeeds. 

    If I create the string from the stream and then get a byte array out of that string, I end up having a byte array of length 1380 and the ZipFile constructor fails. So going throug string somehow messes up the data. 

    Any workaround for this?

Reply Children
No Data