MFC Object serialization in C#

701 Views Asked by At

I am trying to read a binary file in C# which has been written actually using CArchive. I have done most of the part but stuck in reading an object. Instead of writing bool, int, double object has been written into binary.

http://msdn.microsoft.com/en-us/library/3bfsbt0t(v=vs.110).aspx

So original code is something like this.

MyClass myObject;
if (archive.IsStoring()
    archive << myObject;
else
    archive >> myOjbect;

So question is how can I translate this piece of code in C#.

void Read(BinaryReader reader)
{
    // Read MyClass object here.
}
1

There are 1 best solutions below

3
zmbq On

You'll need to create a comparable C# object (you might want to use C++/CLI) and construct it from the file.

It would help if you specified what myObject is.