title: C# equivalent of fread
body: <p>I am in the process of converting some C++ code to C#, I am trying to figure out how I could write out and following C++ code in my C# app and have it do the same thing:</p>
  
  <pre><code>fread(&amp;Start, 1, 4, ReadMunge); //Read File position
  </code></pre>
  
  <p>I have tried multiple ways such as using FileStream:</p>
  
  <pre><code>        using (FileStream fs = File.OpenRead("File-0027.AFS"))
          {
              //Read amount of files from offset 4
              fs.Seek(4, SeekOrigin.Begin);
              FileAmount = fs.ReadByte();
              string strNumber = Convert.ToString(FileAmount);
              fileamountStatus.Text = strNumber;
  
              //Seek to beginning of LBA table
              fs.Seek(8, SeekOrigin.Begin);
              CurrentOffset = fs.Position;
  
              int numBytesRead = 0;
  
              while (Loop &lt; FileAmount) //We want this to loop till it reachs our FileAmount number
              {
                  Loop = Loop + 1;
  
                  //fread(&amp;Start, 1, 4, ReadMunge); //Read File position
                  //Start = fs.ReadByte();
                  //Size = fs.ReadByte();
                  CurrentOffset = fs.Position;
                  int CurrentOffsetINT = unchecked((int)CurrentOffset);
  
                  //Start = fs.Read(bytes,0, 4);
                  Start = fs.Read(bytes, CurrentOffsetINT, 4);
                  Size = fs.Read(bytes, CurrentOffsetINT, 4);
  
  
                  Start = fs.ReadByte();
  
  
              }
          }
  </code></pre>
  
  <p>The problem I keep running into is that <code>Start/Size</code> do not hold the 4 bytes of data that I need.</p>