public static long ReadBufferInt64(byte[] buffer, int bufferOffset) { var longBuffer = new byte[8]; Buffer.BlockCopy(buffer, bufferOffset, longBuffer, 0, 8); return(LittleEndianByteOrder.GetInt64(longBuffer)); }
/// <summary> /// Expect the upcoming 8 bytes are int64, read it and return it; /// </summary> public static long ExpectInt64(this Stream target) { var buff = new byte[8]; if (target.Read(buff) == 8) { return(LittleEndianByteOrder.GetInt64(buff)); } else { throw new EndOfStreamException(); } }