Getting offset from index in binary file
<p>Well, the question says it all. I'm looking for the value in a binary file, and it's location is in the index of the binary file. I'm using the following code, and its not getting me the right bytes back out of the binary file. I'm getting the correct value from the first read, at 0xC, but I'm not converting the offset right. I tried converting it to a string first and getting the right string value, but the moment I try to get it to long its searching the wrong area. Also note that the data I need is actually ox60 BEFORE the index location given to me in the binary.</p>

<pre><code>        long offset = 0;

        //Open read stream
        Stream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        BinaryReader brFile = new BinaryReader(fileStream);

        //Read index to find start position
        fileStream.Seek(0xC, SeekOrigin.Begin);
        byte[] b = brFile.ReadBytes(4);

        //Convert to long value
        for (int x = 0; x &lt; byErr.Length; x++)
            offset = System.Convert.ToInt64(b[x].ToString()); //I'm assuming this is the problem

        //Cleanup
        fileStream.Flush();
        b = null;

        //Read needed value
        fileStream.Position = offset;
        fileStream.Seek(-0x60, SeekOrigin.Current); //The value I need is 0x60 BEFORE the index location
        b = brFile.ReadBytes(4);

        //Cleanup
        fileStream.Flush();
        fileStream.Close();
        brFile.Close();
</code></pre>
