G
Guest
I have a binary file created using C++ that contains an object of the
structure:
struct student
{
int roll_no;
char name[20];
char qualification[50];
};
the following code is used to create and write to the file:
void WriteToFile()
{
student s;
s.roll_no=1;
strcpy(s.name,"nand");
strcpy(s.qualification,"MCA");
CString fileName = "c:\\testdata.dat";
CFile file;
file.Open(fileName,CFile::modeCreate | CFile::modeWrite |
CFile::typeBinary);
file.Write(&s,sizeof(s));
}
Now, I want to read the contents of this binary file (testdata.dat) using a
C# program and store that in a C# structure. Can any body suggest me how to
do this. Sample code would be highly appreciated.
Thanks
structure:
struct student
{
int roll_no;
char name[20];
char qualification[50];
};
the following code is used to create and write to the file:
void WriteToFile()
{
student s;
s.roll_no=1;
strcpy(s.name,"nand");
strcpy(s.qualification,"MCA");
CString fileName = "c:\\testdata.dat";
CFile file;
file.Open(fileName,CFile::modeCreate | CFile::modeWrite |
CFile::typeBinary);
file.Write(&s,sizeof(s));
}
Now, I want to read the contents of this binary file (testdata.dat) using a
C# program and store that in a C# structure. Can any body suggest me how to
do this. Sample code would be highly appreciated.
Thanks