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

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

sql - PostgreSQL automatically update row at specific date -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -