public void BuildPage(long buildPageNumber, long position, byte[] pageBuffer, int offset) { lock (this) { File.Read(position, buffer, 0, 36); var type = BytesUtil.ReadInt8(buffer, 0); var resourceId = BytesUtil.ReadInt8(buffer, 12); var pageNumber = BytesUtil.ReadInt8(buffer, 20); var pageOffset = BytesUtil.ReadInt4(buffer, 28); var pageLength = BytesUtil.ReadInt4(buffer, 32); // Some asserts, if (type != 1) { throw new IOException(String.Format("Invalid page type '{0}' at position '{1}'", type, position)); } if (pageNumber != buildPageNumber) { throw new IOException(String.Format( "The page number '{0}' does not match the number of the page to build ('{1}')", pageNumber, buildPageNumber)); } // Read the content. File.Read(position + 36, pageBuffer, offset + pageOffset, pageLength); } }