System.Windows.Forms.DataBlock.RemoveBytes C# (CSharp) Method

RemoveBytes() public abstract method

public abstract RemoveBytes ( long position, long count ) : void
position long
count long
return void
        public abstract void RemoveBytes(long position, long count);

Usage Example

        /// <summary>
        /// See <see cref="IByteProvider.DeleteBytes" /> for more information.
        /// </summary>
        public void DeleteBytes(long index, long length)
        {
            try
            {
                long bytesToDelete = length;

                // Find the first block affected.
                long      blockOffset;
                DataBlock block = GetDataBlock(index, out blockOffset);

                // Truncate or remove each block as necessary.
                while (bytesToDelete > 0)
                {
                    long      blockLength = block.Length;
                    DataBlock nextBlock   = block.NextBlock;

                    // Delete the appropriate section from the block (this may result in two blocks or a zero length block).
                    long count = Math.Min(bytesToDelete, blockLength - (index - blockOffset));
                    block.RemoveBytes(index - blockOffset, count);

                    if (block.Length == 0)
                    {
                        _dataMap.Remove(block);
                        if (_dataMap.FirstBlock == null)
                        {
                            _dataMap.AddFirst(new MemoryDataBlock(new byte[0]));
                        }
                    }

                    bytesToDelete -= count;
                    blockOffset   += block.Length;
                    block          = (bytesToDelete > 0) ? nextBlock : null;
                }
            }
            finally
            {
                _totalLength -= length;
                OnLengthChanged(EventArgs.Empty);
                OnChanged(EventArgs.Empty);
            }
        }
DataBlock