/// <summary>
        /// Function to delete a directory from the writable area.
        /// </summary>
        /// <param name="path">Path to the directory to delete.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="path"/> is <b>null</b>.</exception>
        /// <exception cref="ArgumentEmptyException">Thrown when the <paramref name="path"/> is empty.</exception>
        /// <exception cref="DirectoryNotFoundException">Thrown when the directory specified by the <paramref name="path"/> could not be found.</exception>
        /// <remarks>
        /// <para>
        /// This will delete a directory, its sub directories, and any files under this directory and sub directories. It will remove all references to those files and directories from the <see cref="IGorgonFileSystemWriter{T}.FileSystem"/>,
        /// and will delete these items from the <see cref="IGorgonFileSystemWriter{T}.WriteLocation"/> if they exist in that location.
        /// </para>
        /// <para>
        /// When a directory is removed from the <see cref="IGorgonFileSystemWriter{T}.FileSystem"/>, it will be removed all mounted file systems. However, the actual directory in the physical file systems will not be touched and the
        /// deleted directory may be restored with a call to <see cref="IGorgonFileSystem.Refresh"/>.
        /// </para>
        /// <para>
        /// <note type="important">
        /// <para>
        /// When restoring files with <see cref="IGorgonFileSystem.Refresh"/>, only the file system object will be updated. The method will not restore any deleted directories in the <see cref="IGorgonFileSystemWriter{T}.WriteLocation"/>.
        /// </para>
        /// </note>
        /// </para>
        /// </remarks>
        /// <seealso cref="IGorgonFileSystem.Refresh"/>
        public void DeleteDirectory(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentEmptyException(nameof(path));
            }

            // If we're not "deleting" the root, then just kill the subdirectory.
            if (path != "/")
            {
                VirtualDirectory directory = _fileSystem.InternalGetDirectory(path);

                if (directory == null)
                {
                    throw new DirectoryNotFoundException(string.Format(Resources.GORFS_ERR_DIRECTORY_NOT_FOUND, path));
                }

                directory.Parent.Directories.Remove(directory);
                _ramFiles.RemoveDirectoryPath(directory.FullPath);
                return;
            }

            // Otherwise, clear the file system files and directories.
            _fileSystem.InternalRootDirectory.Directories.Clear();
            _fileSystem.InternalRootDirectory.Files.Clear();
            _ramFiles.Clear();
        }
        /// <summary>
        /// Function to delete a directory from the writable area.
        /// </summary>
        /// <param name="path">Path to the directory to delete.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="path"/> is <b>null</b>.</exception>
        /// <exception cref="ArgumentEmptyException">Thrown when the <paramref name="path"/> is empty.</exception>
        /// <exception cref="DirectoryNotFoundException">Thrown when the directory specified by the <paramref name="path"/> could not be found.</exception>
        /// <remarks>
        /// <para>
        /// This will delete a directory, its sub directories, and any files under this directory and sub directories. It will remove all references to those files and directories from the <see cref="IGorgonFileSystemWriter{T}.FileSystem"/>,
        /// and will delete these items from the <see cref="IGorgonFileSystemWriter{T}.WriteLocation"/> if they exist in that location.
        /// </para>
        /// <para>
        /// When a directory is removed from the <see cref="IGorgonFileSystemWriter{T}.FileSystem"/>, it will be removed all mounted file systems. However, the actual directory in the physical file systems will not be touched and the
        /// deleted directory may be restored with a call to <see cref="IGorgonFileSystem.Refresh"/>.
        /// </para>
        /// <para>
        /// <note type="important">
        /// <para>
        /// When restoring files with <see cref="IGorgonFileSystem.Refresh"/>, only the file system object will be updated. The method will not restore any deleted directories in the <see cref="IGorgonFileSystemWriter{T}.WriteLocation"/>.
        /// </para>
        /// </note>
        /// </para>
        /// </remarks>
        /// <seealso cref="IGorgonFileSystem.Refresh"/>
        public void DeleteDirectory(string path)
        {
            // If the writable area does not exist at all, then we have nothing to
            // delete.
            var dirInfo = new DirectoryInfo(WriteLocation);

            // If we're not "deleting" the root, then just kill the subdirectory.
            if (path != "/")
            {
                VirtualDirectory directory = _fileSystem.InternalGetDirectory(path);

                if (directory == null)
                {
                    throw new DirectoryNotFoundException(string.Format(Resources.GORFS_ERR_DIRECTORY_NOT_FOUND, path));
                }

                directory.Parent.Directories.Remove(directory);

                if (!dirInfo.Exists)
                {
                    return;
                }

                dirInfo = new DirectoryInfo(GetWriteDirectoryPath(path));
                dirInfo.Delete(true);
                return;
            }

            // Otherwise, clear the file system files and directories.
            _fileSystem.InternalRootDirectory.Directories.Clear();
            _fileSystem.InternalRootDirectory.Files.Clear();

            if (!dirInfo.Exists)
            {
                return;
            }

            PrepareWriteArea();
            dirInfo = new DirectoryInfo(WriteLocation);
            IEnumerable <DirectoryInfo>  directories = dirInfo.EnumerateDirectories("*", SearchOption.TopDirectoryOnly);
            IEnumerable <FileSystemInfo> files       = dirInfo.EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly);

            foreach (DirectoryInfo directoryPath in directories)
            {
                directoryPath.Delete(true);
            }

            foreach (FileSystemInfo file in files)
            {
                file.Delete();
            }
        }