/// <summary>
        /// compare the content of the current directory to the given directory content
        /// using the given compare Option
        /// Note that only Directory are compared the files are ignored
        /// </summary>
        /// <param name="CurrentDirectory">the current instant directory</param>
        /// <param name="directoryToCompare">the directory to compare to</param>
        /// <param name="outputOptions">the out put type</param>
        /// <param name="compareOptions">the compare option, has a default value set to CompareOptions.Name</param>
        /// <returns>the list of found directories</returns>
        /// <exception cref="DirectoryNotFoundException">Current Directory -or- Directory to compare cannot be found.</exception>
        /// <exception cref="Security.SecurityException">The caller does not have the required permission.</exception>
        public static IEnumerable <DirectoryInfo> Compare(
            this DirectoryInfo CurrentDirectory,
            DirectoryInfo directoryToCompare,
            OutputOptions outputOptions,
            CompareOptions compareOptions = CompareOptions.Name)
        {
            if (!CurrentDirectory.Exists || !directoryToCompare.Exists)
            {
                throw new DirectoryNotFoundException(Messages.DirectoriesNotExist);
            }

            switch (compareOptions)
            {
            case CompareOptions.FullName:
                return(DirectoriesHelper.CompareWithFullName(CurrentDirectory, directoryToCompare, outputOptions));

            case CompareOptions.DateOfCreation:
                return(DirectoriesHelper.ComparewithDateOfCreation(CurrentDirectory, directoryToCompare, outputOptions));

            case CompareOptions.Size:
                return(DirectoriesHelper.ComparewithTotalSize(CurrentDirectory, directoryToCompare, outputOptions));

            case CompareOptions.Name:
            default: return(DirectoriesHelper.CompareWithName(CurrentDirectory, directoryToCompare, outputOptions));
            }
        }
        /// <summary>
        /// search in the sub directories of the current instant
        /// </summary>
        /// <param name="CurrentDirectory">the current Directory to search in</param>
        /// <param name="searchKey">the search keyword</param>
        /// <param name="searchOptions">search option</param>
        /// <returns>list of results found</returns>
        /// <exception cref="DirectoryNotFoundException">the current directory cannot be found</exception>
        /// <exception cref="RegexMatchTimeoutException">A time-out occurred.</exception>
        /// <exception cref="ArgumentException">if the search key is null</exception>
        public static IEnumerable <DirectoryInfo> Search(
            this DirectoryInfo CurrentDirectory,
            string searchKey,
            SearchOptions searchOptions)
        {
            if (!CurrentDirectory.Exists)
            {
                throw new DirectoryNotFoundException(Messages.DirectoriesNotExist);
            }

            //search base on the search option
            switch (searchOptions)
            {
            case SearchOptions.Regex:
                return(DirectoriesHelper.SearchWithRegex(CurrentDirectory, searchKey));

            case SearchOptions.Name:
            default: return(DirectoriesHelper.SearchWithName(CurrentDirectory, searchKey));
            }
        }
 /// <summary>
 /// Copy the directory to the desktop folder
 /// </summary>
 /// <param name="CurrentDirectory">the current directory instant</param>
 /// <param name="copySubDirs">true to copy sub directory</param>
 /// <param name="overwriteFiles">true to overWrite existing files, by default set to false</param>
 /// <exception cref="UnauthorizedAccessException">The caller does not have the required permission.</exception>
 /// <exception cref="DirectoryNotFoundException">if the Directory not exist</exception>
 /// <exception cref="Security.SecurityException"> The caller does not have the required permission.</exception>
 /// <exception cref="PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.
 /// For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.</exception>
 /// <exception cref="IOException">An error occurs, or the destination file already exists and overwrite is false.</exception>
 public static void CopyToDesktop(this DirectoryInfo CurrentDirectory,
                                  bool copySubDirs    = true,
                                  bool overwriteFiles = false)
 {
     CurrentDirectory.Copy(DirectoriesHelper.GetDesktopPath());
 }
 /// <summary>
 /// move the folder to the desktop folder
 /// </summary>
 /// <param name="CurrentDirectory">directory to move</param>
 /// <exception cref="DirectoryNotFoundException">The Current directory cannot be found.</exception>
 /// <exception cref="IOException"> An attempt was made to move a directory to a different volume.
 /// -or- destDirName already exists.
 /// -or- You are not authorized to access this path.
 /// -or- The directory being moved and the destination directory have the same name.</exception>
 /// <exception cref="Security.SecurityException">The caller does not have the required permission.</exception>
 public static void MoveToDesktop(this DirectoryInfo CurrentDirectory)
 {
     CurrentDirectory.Move(DirectoriesHelper.GetDesktopPath());
 }