Advertisement
Guest User

Untitled

a guest
Sep 12th, 2012
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             using (OpenFileDialog fileDialog = new OpenFileDialog())
  4.             {
  5.                 if (fileDialog.ShowDialog() != DialogResult.Cancel)
  6.                 {
  7.                     textBox1.Text = fileDialog.FileName;
  8.                     using (BinaryReader fileBytes = new BinaryReader(new MemoryStream(File.ReadAllBytes(textBox1.Text))))
  9.                     {
  10.                         //Get the hex data in bytearray format
  11.                         //This won't be displayed
  12.                         int length = (int)fileBytes.BaseStream.Length;
  13.                         byte[] hex = fileBytes.ReadBytes(length);
  14.                         File.WriteAllBytes(@"c:\temp_file.txt", hex);
  15.  
  16.                         //This is what's displayed.
  17.                         //Remember to make changes to the byte array
  18.                         //and then update the view.
  19.                         string tempStr = BitConverter.ToString(hex).Replace("-", " ");
  20.                         richTextBox1.Text = tempStr;
  21.                         bool isColour = true;
  22.  
  23.  
  24.  
  25.  
  26.                         for (int i = 0; i < richTextBox1.TextLength; i++)
  27.                             if (i % 4 == 1)
  28.                             {
  29.                                 richTextBox1.SelectionStart = i;
  30.                                 richTextBox1.SelectionLength = 2;
  31.                                 richTextBox1.SelectionColor = Color.Red;
  32.                             }
  33.                     }
  34.                 }
  35.             }
  36.  
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement