serialization - XmlSerialize directly to GZipStream throws magic number exception on Decompression -
I am trying to sequence an object sequence to XML though my object is a normal list containing many records and is very consumable to either the causes serializer memory I tried to order directly to a GZipStream with the following code:
dim formatter XmlSerializer = XmlSerializerFactory.GetSerializerForType (_type) _ms New MemoryStream As using (as) gzstream U Use as GZipStream (_ms, CompressionMode.Compress, it is true) _ms.Position = 0 FormatterkSerialize (GzStream, Obj) _ms.Position = 0 GzStreamkFlush () GzStreamkClose () End _ms.Position = 0 dim DecompressData (using byte (as the new GZipStream use as gzStream) _ms, CompressionMode.Decompress) ReDim decompressData (9000 - 1) 'the number does not matter, the data in your test sample small slow lane integer = gzStream.Read (decompressData, 0, decompressData.Length) to use in the end as the end although I run a InvalidDataException The front GZip magic number in the header is not correct. Make sure that you are passing in a GZip stream when trying to read data in the decompressData array When I first and then a different memory stream sequence that section like sec: ..
Comments
Post a Comment