views:

26

answers:

1

Hi all,

I realize easily serialisation and deserialisation of my objet with XML file. I am wondering if it is possible to do that with binary file.

Thanks !

A: 

I don't think you can convert it to XML, I would convert the binary file to a base 64 string.

    Stream fileStream = file.OpenRead();
    stream.Seek(0, SeekOrigin.Begin); 
    byte[] binaryData = new Byte[stream.Length]; 
    long bytesRead = stream.Read(binaryData, 0, (int)stream.Length); 

    string base64String = 
            System.Convert.ToBase64String(binaryData, 
                                          0, 
                                          binaryData.Length); 

    return base64String;
RHLopez