Exemplo n.º 1
0
        private void LoadBits()
        {
            BaseStream.Position = BaseStream.Length - sizeof(int);

            byte[] bytArrayLength = new byte[sizeof(int)];
            BaseStream.Read(bytArrayLength, 0, bytArrayLength.Length);
            int intBytesLength = BitConverter.ToInt32(bytArrayLength, 0);

            if (intBytesLength > 0)
            {
                BaseStream.Position = BaseStream.Length - intBytesLength - sizeof(int);

                byte[] bytBitsData = new byte[intBytesLength];
                BaseStream.Read(bytBitsData, 0, bytBitsData.Length);

                BitArray objBitArray  = new BitArray(bytBitsData);
                bool[]   objBoolArray = new bool[objBitArray.Count];
                objBitArray.CopyTo(objBoolArray, 0);

                Bits.Clear();
                Bits.AddRange(objBoolArray);

                BaseStream.SetLength(BaseStream.Length - intBytesLength - sizeof(int));
                BaseStream.Position = 0;
            }
            else
            {
                BaseStream.SetLength(BaseStream.Length - sizeof(int));
                BaseStream.Position = 0;
            }
        }