Binary serialization 
Author Message
 Binary serialization

I cant understand how to do binary serialization, i.e.  I want to serialize
binary data ( about 50 bytes long). I can only find functions for serialize
Strings, Ints, doubles,etc in the SerializationInfo class, but no function
for serializing binary data ( similar to the PX_Blob function in MFC ).

I hope that I have worded my question clear enough; that is I want to know
how to serialize binary data ,  and not serialize data in binary format( for
which, I guess, you could use the BinaryFormatter class)

Thanks
Atul



Wed, 21 Sep 2005 06:10:59 GMT  
 Binary serialization
Atul,

    It doesn't matter what the formatter is.  The Serialize method on any
formatter will take a Stream and an object.  Just pass the stream you want
to serialize to, and the object (in this case, your byte array) and then the
contents will be written to the stream.

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]


Quote:
> I cant understand how to do binary serialization, i.e.  I want to
serialize
> binary data ( about 50 bytes long). I can only find functions for
serialize
> Strings, Ints, doubles,etc in the SerializationInfo class, but no function
> for serializing binary data ( similar to the PX_Blob function in MFC ).

> I hope that I have worded my question clear enough; that is I want to know
> how to serialize binary data ,  and not serialize data in binary format(
for
> which, I guess, you could use the BinaryFormatter class)

> Thanks
> Atul



Wed, 21 Sep 2005 06:14:37 GMT  
 Binary serialization
This is from memory, but it should be pretty close:

Dim formatter As New BinaryFormatter()
Dim memory As New MemoryStream()
Dim data(50) As Byte

formatter.Serialize(memory, data)

The result of this is that the memory stream object, memory, will contain a
serialized representation of your binary data - or any other data you pass
for that matter.

Rocky
--
Rockford Lhotka
Author of 'Expert One-on-One Visual Basic.NET Business Objects'


Quote:
> I cant understand how to do binary serialization, i.e.  I want to
serialize
> binary data ( about 50 bytes long). I can only find functions for
serialize
> Strings, Ints, doubles,etc in the SerializationInfo class, but no function
> for serializing binary data ( similar to the PX_Blob function in MFC ).

> I hope that I have worded my question clear enough; that is I want to know
> how to serialize binary data ,  and not serialize data in binary format(
for
> which, I guess, you could use the BinaryFormatter class)

> Thanks
> Atul



Wed, 21 Sep 2005 08:02:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Binary Serialization with an object that has events

2. Serialization in Binary Format

3. Proposal: alt.binaries.examples.vb4 , alt.binaries.examples.vcpp , alt.binaries.examples.java

4. Proposal: alt.binaries.examples.vb4 , alt.binaries.examples.vcpp , alt.binaries.examples.java

5. Serialization to XML & porting compatibility

6. Self Serialization

7. serialization question

8. Custom Serialization

9. Serialization of Collection in VB.NET

10. Serialization Question

11. Serialization - deserialize classes that has been extended

12. XML Serialization Versioning

 

 
Powered by phpBB® Forum Software