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 0x02BDBFEBat 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?
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?
I managed to solve this issue by converting the stream to base64string. This way it works to both ways without any problems. Hope this info helps someone else too in the future.