title: How to read binary files until EOF in C#
body: <p>I have a function to write some data into a binary file</p>
  
  <pre><code>private void writeToBinFile (List&lt;MyClass&gt; myObjList, string filePath)
  {
      FileStream fs = new FileStream(filePath, FileMode.Create);
      BinaryWriter bw = new BinaryWriter(fs);
  
      foreach (MyClass myObj in myObjList)
      {
          bw.Write(JsonConvert.SerializeObject(myObj));
      }
      bw.Close();
      fs.Close();
  
  }
  </code></pre>
  
  <p>I am looking something like </p>
  
  <pre><code>FileStream fs = new FileStream(filePath, FileMode.Create);
  BinaryReader bw = new BinaryReader(fs);
  
  while (!filePath.EOF)
  {
      List&lt;MyClass&gt; myObjList = br.Read(myFile);
  }
  </code></pre>
  
  <p>anyone can help with this?
  thanks in advance</p>