R
RP2001
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.
Another strange thing that I noticed is that the first ASCII character
that is suppose to be there as part of the string being read out, is
not being interpreted.
Two other things I want to point out that is specific to my situation
and it is that the string being read out from the binary file has two
consecutive carriage returns and line feeds ("\r\n\r\n"). Also I'm
trying to read out two string consecutively. Could these two aspects
attribute to the problem?
Example, when I use the Studio.NET debugger to see what is contained
in my_variable_of_type_CString, I get something like this:
my_variable_of_type_CString = "ew York City\vNext String to be read
out\0\0\0 . . . (garbage until the end of file"
Any help will be GREATLY appreciated. Thanks in advance.
-RP
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.
Another strange thing that I noticed is that the first ASCII character
that is suppose to be there as part of the string being read out, is
not being interpreted.
Two other things I want to point out that is specific to my situation
and it is that the string being read out from the binary file has two
consecutive carriage returns and line feeds ("\r\n\r\n"). Also I'm
trying to read out two string consecutively. Could these two aspects
attribute to the problem?
Example, when I use the Studio.NET debugger to see what is contained
in my_variable_of_type_CString, I get something like this:
my_variable_of_type_CString = "ew York City\vNext String to be read
out\0\0\0 . . . (garbage until the end of file"
Any help will be GREATLY appreciated. Thanks in advance.
-RP