1

I have some code written in MFC which writes data to a file. Now I am rewriting that code in C#. In MFC code, data is being written in file using CArchive. Now I am thinking to use BinaryReader in C# to read the data from the file.

So my question is that are they same CArchive and BinaryReader? If not then what is the difference and what I should use.

I am not good in MFC and I am assuming that CArchive writes binary data in file. Is this assumption right?

fhnaseer
  • 7,159
  • 16
  • 60
  • 112
  • What is the data being written to the file with MFC?? – Ahmed KRAIEM May 28 '13 at 09:38
  • int, uint, short, double, CString – fhnaseer May 28 '13 at 09:45
  • Yes CArchive writes binary data, but in a format that is unique to MFC. It is not related to BinaryReader. The only way to understand and parse the CArchive data is to study the MFC source code. It would probably be easier to use MFC in a DLL that you can call from C# – ScottMcP-MVP May 28 '13 at 13:44
  • int, uint, short, double is stored directly "as is" in a CArchive. CStrings is slightly more complicated. The string length is stored in a byte, a word or a dword and then it is stored "as is" in the CArchive. Look at the MFC sourc code to find out how this is done exactly. I've done this before and it's pretty straight forward. – Jabberwocky May 28 '13 at 14:02

0 Answers0