Home All Groups Group Topic Archive Search About

BinaryFormatter serialization size.

Author
27 Jul 2006 5:28 PM
Ken Varn
How can I determine the size of the data that a BinaryFormatter will produce
when serializing an object?  I basically want to know how many bytes an
object with SerializableAttribute will produce if it is serialized to a
stream.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Author
28 Jul 2006 8:17 AM
Frans Bouma [C# MVP]
Ken Varn wrote:

> How can I determine the size of the data that a BinaryFormatter will
> produce when serializing an object?  I basically want to know how
> many bytes an object with SerializableAttribute will produce if it is
> serialized to a stream.

    You can't determine that up front, so you have to determine that
using a memorystream and checking the size of the stream after
serializing the data into the memorystream.

        FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

AddThis Social Bookmark Button