/// <summary> /// Reads the length of a field at the specified offset in the file /// </summary> /// <param name="offset">Offset into the file to read the field length from</param> /// <returns>A LengthResult</returns> internal LengthResult ReadLength(long offset) { // read in length information int lengthValue; int lengthLength = fileStream.ReadData(buffer, 1, offset); if (buffer[0] != 0xFF) { // one byte is enough lengthValue = Convert.ToInt32(buffer[0]); } else { // read in next 4 bytes lengthLength += fileStream.ReadData(buffer, 4); // reconstruct the length lengthValue = BitConverter.ToInt32(buffer, 0); } return(new LengthResult { LengthLength = lengthLength, ValueLength = lengthValue }); }