C
cgladd87
I'm using a stream reader to read a hex file on the pda from a C#
program that I am converting from VB.net. The problem is that on some
of the lines, the hex is changed from its actual values. The same file
reads in fine in the VB.net program and I have checked to the bytes in
the file and am sure that they are correct. The first line of the hex
file reads in correctly but all subsequent lines have a 2 subtracted
from one of the hex numbers and 2 added to the last hex number. It is
always the same position and even though I'm just reading this in as
as string, I'm relatively sure something intelligent is happening
because if needed the subtraction will borrow from the number in front
of it, changing two of the hex numbers. This only happens with my
Chinese PDA and only when I'm using the C# version of the program. I'm
using a Chinese Dell Axim 51 for this project. I don't know what could
be changing the file or why but I need to accurately read in the hex
number as they are the program for our micro. I've tried different
encodings for the stream as well as a BinaryReader and end up with the
same result. My code is as follows:
FileStream inFile = new
FileStream(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
+ "\\Firmware\\" + filename, FileMode.Open, FileAccess.Read,
FileShare.None);
StreamReader sr = new StreamReader(inFile,Encoding.ASCII,
false);
line_input = sr.ReadLine();
while (line_input != null)
{
(DO WORK ON THE STRING)
Application.DoEvents();
line_input = sr.ReadLine();
}
sr.Close();
Thanks,
Chris
program that I am converting from VB.net. The problem is that on some
of the lines, the hex is changed from its actual values. The same file
reads in fine in the VB.net program and I have checked to the bytes in
the file and am sure that they are correct. The first line of the hex
file reads in correctly but all subsequent lines have a 2 subtracted
from one of the hex numbers and 2 added to the last hex number. It is
always the same position and even though I'm just reading this in as
as string, I'm relatively sure something intelligent is happening
because if needed the subtraction will borrow from the number in front
of it, changing two of the hex numbers. This only happens with my
Chinese PDA and only when I'm using the C# version of the program. I'm
using a Chinese Dell Axim 51 for this project. I don't know what could
be changing the file or why but I need to accurately read in the hex
number as they are the program for our micro. I've tried different
encodings for the stream as well as a BinaryReader and end up with the
same result. My code is as follows:
FileStream inFile = new
FileStream(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
+ "\\Firmware\\" + filename, FileMode.Open, FileAccess.Read,
FileShare.None);
StreamReader sr = new StreamReader(inFile,Encoding.ASCII,
false);
line_input = sr.ReadLine();
while (line_input != null)
{
(DO WORK ON THE STRING)
Application.DoEvents();
line_input = sr.ReadLine();
}
sr.Close();
Thanks,
Chris