Пример #1
0
        public ConcurrentDictionary <string, List <string> > GroupAllFilesInDirectoryWithAnyDuplicates(string rootDirectory, out StringBuilder errorsToReturn)
        {
            Stack <string> directoriesToBeProcessed = InitialiseCollectionOfDirectoriesToBeProcessed(rootDirectory);

            while (directoriesToBeProcessed.Count > 0)
            {
                string currentDir = directoriesToBeProcessed.Pop();

                AddSubDirectoriesToListOfDirectoriesToBeProcessed(currentDir, directoriesToBeProcessed);

                string[] filePaths = _iOHelper.GetFilesInDirectory(currentDir);

                for (var index = 0; index < filePaths.Length; index++)
                {
                    try
                    {
                        AddFileToGroupedCollection(filePaths[index]);
                    }
                    catch (Exception ex)
                    {
                        ErrorsProcessingFiles.AppendLine($"Error occured processing file {filePaths[index]}: {ex.Message}");
                    }
                }
            }

            errorsToReturn = ErrorsProcessingFiles ?? null;

            return(filesGroupedWithDuplicates);
        }