public static XPacketType ReadNextPacket(FileStream stream, out int totalSize) { totalSize = BitConverter.ToInt32(stream.Read(4), 0); return (XPacketType) stream.ReadByte(); }