Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- using (OpenFileDialog fileDialog = new OpenFileDialog())
- {
- if (fileDialog.ShowDialog() != DialogResult.Cancel)
- {
- textBox1.Text = fileDialog.FileName;
- using (BinaryReader fileBytes = new BinaryReader(new MemoryStream(File.ReadAllBytes(textBox1.Text))))
- {
- //Get the hex data in bytearray format
- //This won't be displayed
- int length = (int)fileBytes.BaseStream.Length;
- byte[] hex = fileBytes.ReadBytes(length);
- File.WriteAllBytes(@"c:\temp_file.txt", hex);
- //This is what's displayed.
- //Remember to make changes to the byte array
- //and then update the view.
- string tempStr = BitConverter.ToString(hex).Replace("-", " ");
- richTextBox1.Text = tempStr;
- bool isColour = true;
- for (int i = 0; i < richTextBox1.TextLength; i++)
- if (i % 4 == 1)
- {
- richTextBox1.SelectionStart = i;
- richTextBox1.SelectionLength = 2;
- richTextBox1.SelectionColor = Color.Red;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement