c# - How to serialize object to xml and compress in memory -
In my application, I should serial a large object for XML string. But then serialized throwing system. How can I sort out the object with exception and compression without otheoff memory exception?
Public Static String GenerateXMLData & lt; T & gt; (T data) {byte [] bytes; (Var using memoryStream = new MemoryStream ()) (var gZipStream = new GZipStream (memoryStream, CompressionMode.Compress)) {BinaryFormatter binaryFormatter = New BinaryFormatter (); Binary formatting Serialize (GJprstream, data); } Bytes = MemoryStream. ToArray (); } Return encoding. UTF8.GetString (bytes); }
There are very good answeers on the stackoverflow which one has accesed through
P>
:)
Comments
Post a Comment