/// <summary>
        ///         removes an item entry from this directory.
        /// </summary>
        /// <param name="itemToRemove">the item to remove.</param>
        internal void RemoveItem(VirtualItem itemToRemove)
        {
            IEnumerable<VirtualItem> items = ReadAllItems();

                        var dataWriter = new DataWriter();

                        foreach (VirtualItem remainingItem in items.Where(item => item.FileNumber != itemToRemove.FileNumber))
                        {
                                SerializeItem(remainingItem, dataWriter);
                        }

                        FileStream stream = GetFileStream();
                        byte[] data = dataWriter.GetData();
                        stream.Write(BitConverter.GetBytes((ulong) data.Length));
                        stream.Write(data);
        }
        internal void RenameItem(VirtualItem virtualItem, string newName)
        {
            var dataWriter = new DataWriter();

                        foreach (VirtualItem item in ReadAllItems())
                        {
                                if (item.FileNumber == virtualItem.FileNumber)
                                {
                                        item.Name = newName;
                                }

                                SerializeItem(item, dataWriter);
                        }

                        FileStream stream = GetFileStream();
                        byte[] data = dataWriter.GetData();

                        if (stream.Length < data.Length + 8)
                        {
                                ContainerFile.ChangeFileSize(FileNumber, (uint) (data.Length + 8));
                        }

                        stream = GetFileStream();
                        stream.Write(BitConverter.GetBytes((ulong) data.Length));
                        stream.Write(data);
        }
        /// <summary>
        ///         adds an item to this directory.
        /// </summary>
        /// <param name="itemToAdd">the item to add.</param>
        internal void AddItem(VirtualItem itemToAdd)
        {
            FileStream fileStream = GetFileStream();

                        long currentSize = BitConverter.ToInt64(fileStream.Read(8), 0);

                        var dataWriter = new DataWriter();
                        SerializeItem(itemToAdd, dataWriter);
                        byte[] data = dataWriter.GetData();

                        long newSize = currentSize + data.Length;

                        if (fileStream.Length < newSize + 8)
                        {
                                ContainerFile.ChangeFileSize(FileNumber, (uint) (newSize + 8));
                        }

                        fileStream = GetFileStream();
                        fileStream.Write(BitConverter.GetBytes(newSize));
                        fileStream.Seek(currentSize + 8, SeekOrigin.Begin);
                        fileStream.Write(data);
        }