I am trying to use C# to read the contents of a binary file written by a VB6 application. I have used the article "Fast Binary Reading" at http://www.codeproject.com/cs/files/fastbinaryfileinput.asp
as a guide, opting to use the BinaryReader to do a ReadString(), ReadInt64(), etc into the members of a struct patterned after the User Defined Types created in the VB6 application.
When I step through the program, I see a truncated version of, say, the invoice number 0071383. The VS 2005 express shows me " \0007138" when I place the pointer over the struct member to see what value it is holding. However, when I test the output in a messagebox, I get a blank. Not even the literal strings I put in MessageBox show. The value in the invoice date shows as: "\b\020071002\b\0H ýýýý\0\0ýý\0\0\0\0ýh\0\0\
\0\0" when I work in debug mode. Iit is a concat of the date and an employee code ('H'). But, like I say, nothing shows up on the message box.
fs = new FileStream(FullPath, FileMode.Open,FileAccess.R
br = new BinaryReader(fs);
/* Snippet from article */
while (br.PeekChar() != -1)
i06.InvoiceNumber = br.ReadString();
i06.InvoiceDate = br.ReadString();
eNumber + " The invoice date: " + i06.InvoiceDate , "Invoice Number and Date"); // I come up with blanks here
break; // i'm just trying to get one or two successful reads before reading whole file
} // end while
The VB6 Get method will read a binary file's contents into a user defined type quite easily, even if one of the elements is s UDT. I'm not really finding a C# equivalent to this.
I am trying just to get these two tiny members to fill the struct elements before I go on. What do I need to know about C# data types and VB6 data types in order to bring the data in ? I tried changing the binary reader encoding property, but that did not render any helpful results. I got either gibberish or blanks. What might I be missing?