How can i read binary data?

G

Guest

I store a serialized object in db as binary data. I want to read it and write
it to a byte array (byte[] xxx). I saw examples in forums, but all of them
write the data to a file on local drive. I want to read all the bytes and
serialize them to get the object without creating a file and writing data
into that file. How can i do that?

Thanks...
 
A

Adam Benson

Here's a rough example :

public static object DeserialiseFromString(string s)

{

SoapFormatter bf = new SoapFormatter();

byte[] b = System.Text.Encoding.UTF8.GetBytes( s );

MemoryStream ms = new MemoryStream(b);

ms.Position = 0;

object o = bf.Deserialize(ms);

return o;

}



HTH, Adam.

=================
 
G

Guest

Thanks but i dont have problem in deserializing the byte[] data. I have
problem in reading binary data and writing it into byte array.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top