title: Search for hex code in a file
body: <p>I want to make a program which allows users to search for a specific hex code within a file and the output would be the offset or not found .
  The code that i have so far is :</p>
  
  <pre><code> namespace search
   {
  class Program
  {
      static void Main(string[] args)
      {
          System.IO.BinaryWriter bw = new BinaryWriter(File.OpenWrite("C:\\1.txt"));
          bw.BaseStream.Position = 3;
          bw.Write((byte)0x01);
          bw.Close();
          Console.WriteLine("Wrote the byte 01 at offset 3!");
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have looked everywhere on the web and did not found anything usefull , is it possible to search for hex code and have an output with the offset ?</p>
  
  <p>EDIT1:</p>
  
  <p>Lets say we have this file 1.txt and at this offset 0x1300 we have this hex code 0120 / 0x01 0x20 / "0120" ( i dont know how to write it ) . After opening the program it will ask you with a console.readline what hex code to search for and the output will be 0x1300</p>
  
  <p>EDIT2:
  my question is similar to this one 
  <a href="https://stackoverflow.com/questions/13362103/vb-net-get-offset-address">VB.Net Get Offset Address</a>
  and it have a solution but in vb.net</p>