EDIT: Sorry for the inconsistency but I re-edited my whole post, lol.
I still have a problem, just a different one, so no need to delete the thread.
New problem: I have successfully read the bytes of a file into a byte array. The hex of the file is successfully being placed into a textbox. The ascii is properly placed into the adjunct textbox if it is a text file. Binary files don't play nice, are the nulls in a binary file terminating it or something? (I'm really a C language fogey).
Why does the ASCII textbox terminate with binary files?
Furthermore, how can I segment the output of the hex into batches of 2 and lines of 16?
EDIT: Could anyone also help me with figuring out how
to link my Hexadecimal and ASCII textboxes together
so that highlighting in one highlights the same byte in the other and also links together the scrolling thereof and so on and so forth?
//declared some utility variables
txtHex.Text = "";
txtASCII.Text = "";
//blanked the textbox
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "All Files|*.*";
//opened file from openfiledialog for reading
FileStream fs = new FileStream(ofd.FileName, FileMode.Open,
filesize = fs.Length;
byte bytes = new byte[filesize];
BinaryReader br = new BinaryReader(fs);
bytes = br.ReadBytes((int)filesize);
label2.Text = Convert.ToString(bytes.Length) + " bytes";
StringBuilder stringb = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
txtHex.Text = stringb.ToString();
txtASCII.Text = System.Text.ASCIIEncoding.ASCII.GetString(bytes);
// this is to solve an error where it would crash if you hit cancel