I was directed on how to read a hex file into an array and it worked out very well. I got the array loaded up from a file that contained hex bytes between 00 and ff. However, when I when to look at the decimal values in the array by use of the "value.Text = myarray[myByte].ToString();", everything worked fine if the value of the byte was 127 or less. Any value above 127 returned a value of 65533. The type of "value" is uint. What is happening?
NOVICE3

Hmmm...that's odd.

I would say that the values are probably being loaded incorrectly OR they are loaded correctly and it's reporting correctly, just the text file is setup wrong.

The hex value of 128 is 80, I wonder if the hex text file uses FF00 or something goofy.

Could you maybe attach your hex file and the methods that you use to read the text file, load the values into an array and the method you use to get the value of an item in the array?

What do you mean that the type of value is uint? uint doesn't have a .Text property so I have no idea what you are talking about.

Post some code, because I can't recreate this issue at all.

I think he meant the array is uint...but I dunno...I thought the same thing, but was hoping some code would shed some light.

//open the file
            DialogResult responsibleDialogResult;

            //begin in the project folder
            openFileDialog1.InitialDirectory = "C:";

            //Display the File Open Dialog Box
            responsibleDialogResult = openFileDialog1.ShowDialog();
            if (responsibleDialogResult != DialogResult.Cancel)
            {
                //User did not select cancel so open the file

                StreamReader fileReader = new StreamReader(openFileDialog1.FileName);
                FileInfo f = new FileInfo("ANSWRFIL.HEX");
                fileLengthAnswer = f.Length;
                tempArray[0] = Convert.ToUInt32(fileLengthAnswer);

                //beyond here  --  ?

             {

Edited 5 Years Ago by __avd: Added [code] tags.

if (responsibleDialogResult != DialogResult.Cancel)

Is it so hard to say if (responsibleDialogResult == DialogResult.OK) ?
What is tempArray ?

Comments
I hate when people do that

Hmmm...

Well...it appears to me that you are not reading the information in the file, not the data anyway, but your loading an array (not sure of what type, but it looks like an integer array) with one entry, the size (length) of the file. Maybe I'm missing something but could you attach a copy of the ANSWRFIL.HEX? Put it in a zip file so you can upload it, or it wont upload.

Also, could you share the code that you use to actually read the data from the file? If you can use the code tags too :) Helps with readability.

This article has been dead for over six months. Start a new discussion instead.