title: C# - Read bytes from file from a specific string
body: <p>I'm trying to parse a <a href="http://opencrg.org/index.html" rel="nofollow noreferrer">crg-file</a> in C#. The file is mixed with plain text and binary data. The first section of the file contains plain text while the rest of the file is binary (lots of floats), here's an example:</p>
  
  <pre><code>$
  $ROAD_CRG
  reference_line_start_u   =  100
  reference_line_end_u     =  120
  $
  $KD_DEFINITION
  #:KRBI
  U:reference line u,m,730.000,0.010
  D:reference line phi,rad
  D:long section 1,m
  D:long section 2,m
  D:long section 3,m
  ...
  $
  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  �@z����RAΣ����\�l
  ...
  </code></pre>
  
  <p>I know I can read bytes starting at a specific offset but how do I find out which byte to start from? The last row before the binary section will always contain at least four dollar signs "$$$$". Here's what I've got so far:</p>
  
  <pre><code>using var fs = new FileStream(@"crg_sample.crg", FileMode.Open, FileAccess.Read);
  
  var startByte = ??; // How to find out where to start?
  
  using (BinaryReader reader = new BinaryReader(fs))
  {
      reader.BaseStream.Seek(startByte, SeekOrigin.Begin);
      var f = reader.ReadSingle();
      Debug.WriteLine(f);
  }
  </code></pre>