title: Opening a File in C# using FileStream
body: <p>I am trying to open a Binary file that I plan on converting to hex  but I am running into issues with reading the file via FileStream, </p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      openFD.Title = "Insert a BIN file";
      openFD.InitialDirectory = "C:"; // Chooses the default location to open the file
      openFD.FileName = " "; // Iniitalizes the File name
      openFD.Filter = "Binary File|*.bin|Text File|*.txt"; // FIlters the types of files allowed to by chosen
  
      if (openFD.ShowDialog() != DialogResult.Cancel)
      {
          chosenFile = openFD.FileName;
          string directoryPath = Path.GetDirectoryName(chosenFile); // Returns the directory and the file name to reference the file
          string dirName = System.IO.Path.GetDirectoryName(openFD.FileName); // Returns the proper directory with which to refernce the file 
          richTextBox1.Text += dirName;
          richTextBox1.Text += chosenFile;
          FileStream InputBin = new FileStream(
              directoryPath, FileMode.Open, FileAccess.Read, FileShare.None);
      }
  }
  </code></pre>
  
  <p>I am receiving an error saying that the access to the path is denied, any ideas?</p>
  
  <p>Now that I have gotten that error taken care of I have ran into another Issue, I can read the binary file, but I want to display it as a Hex file, I'm not sure what I am doing wrong but I'm not getting an output in HEX, it seems to be Int values...</p>
  
  <pre><code>if (openFD.ShowDialog() != DialogResult.Cancel)
          {
  
              chosenFile = openFD.FileName;
              string directoryPath = Path.GetDirectoryName(chosenFile); 
              string dirName = System.IO.Path.GetDirectoryName(openFD.FileName);
              using (FileStream stream = new FileStream(chosenFile, FileMode.Open, FileAccess.Read))
              {
                  size = (int)stream.Length;
                  data = new byte[size];
                  stream.Read(data, 0, size);
              }
  
              while (printCount &lt; size)
              {
                  richTextBox1.Text += data[printCount];
                  printCount++;
              }
  </code></pre>