title: How to read byte blocks into struct
body: <p>I have this resource file which I need to process, wich packs a set of files. </p>
  
  <p>First, the resource file lists all the files contained within, plus some other data, such as in this struct:</p>
  
  <pre><code>struct FileEntry{
       byte Value1;
       char Filename[12];
       byte Value2;
       byte FileOffset[3];
       float whatever;
  }
  </code></pre>
  
  <p>So I would need to read blocks exactly this size.</p>
  
  <p>I am using the Read function from FileStream, but how can I specify the size of the struct?
  I used:</p>
  
  <pre><code>int sizeToRead = Marshal.SizeOf(typeof(Header));
  </code></pre>
  
  <p>and then pass this value to Read, but then I can only read a set of byte[] which I do not know how to convert into the specified values (well I do know how to get the single byte values... but not the rest of them).</p>
  
  <p>Also I need to specify an unsafe context which I don't know whether it's correct or not...</p>
  
  <p>It seems to me that reading byte streams is tougher than I thought in .NET :)</p>
  
  <p>Thanks!</p>