title: How to open a file as binary mode and replace hex strings?
body: <p>I need open and edit a executable file in binary mode, to replace hex value as string.</p>
  
  <p>In PHP, looks like this:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      $fp = fopen('file.exe', 'r+');
      $content = fread($fp, filesize('file.exe'));
      fclose($fp);
      print $content;
      /* [...] This program cannot be run in DOS mode.[...] */
  ?&gt;
  </code></pre>
  
  <p>How I get it in C#?</p>