Re: Interesting problem: serializing in with MFC CArchive, reading out using C# BinaryReader
From: RP2001 (ratcharit_at_gmail.com)
Date: 11/12/04
- Next message: Steve Briers: "24-bit memory DC"
- Previous message: CheckAbdoul: "Re: Help from expert needed :( VC7.1"
- In reply to: Scott McPhillips [MVP]: "Re: Interesting problem: serializing in with MFC CArchive, reading out using C# BinaryReader"
- Messages sorted by: [ date ] [ thread ]
Date: 12 Nov 2004 07:31:27 -0800
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message news:<e6CJzmEyEHA.2540@TK2MSFTNGP09.phx.gbl>...
> RP2001 wrote:
>
> > I've serialized in various variables of various types (mainly CString,
> > int, double) into an instantiated MFC CArchive class and saved it as a
> > binary file.
> >
> > I am able to open the binary file and read out the individual
> > variables fine with an MFC application. However I cannot read the
> > binary file correctly with a C#.NET application, where I'm using the
> > BinaryReader Class. Doing some debugging I noticed that the problem
> > occured at this C# line of code:
> >
> > my_variable_of_type_CString =
> > instantiated_CSharp_binaryreader.ReadString();
> >
> > When this line of code execute, the binary reads out the ENTIRE
> > remainder of the file. So I thought is this one of those hairy, good
> > old string termination issues, but I've checked the byte representing
> > the string termination and it's there.
> >
>
> Actually, a CString in a CArchive file does not have a terminator. You
> are assuming that the C# ReadString knows how MFC encodes a string in a
> CArchive. I don't know what C# does, but this seems a very unlikely
> assumption. CArchive prefixes the string with its length, and the
> length of the length field is variable and binary. So you have a lot
> more work to do - translating the CArchive code - before you can expect
> to properly interpret a binary image of a CArchive.
Huh . . . What is the byte that I see after the CString that is being
interpreted as ASCII "\v"? Isn't that some sort of string termination?
Thanks for your input, Scott.
- Next message: Steve Briers: "24-bit memory DC"
- Previous message: CheckAbdoul: "Re: Help from expert needed :( VC7.1"
- In reply to: Scott McPhillips [MVP]: "Re: Interesting problem: serializing in with MFC CArchive, reading out using C# BinaryReader"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|