public void Reorganize() { if (_directoriesList.Count < 2) return; Directory unitedResultDirectory = new Directory(); List<Directory> directoriesToRemove = new List<Directory>(); foreach (Directory directory in _directoriesList) { if (directory.Files.Count >= _countOfFilesInDirectoryToUnite) continue; unitedResultDirectory.Files.AddRange(directory.Files.FilesList); directoriesToRemove.Add(directory); } foreach (Directory directory in directoriesToRemove) _directoriesList.Remove(directory); unitedResultDirectory.Name = "Union"; _directoriesList.Insert(0, unitedResultDirectory); }
public void Add(string directoryName, string filePath) { Directory directory; int indx = _directoriesList.FindIndex(x => { return x.Name.Equals(directoryName); }); if (indx == -1) { directory = new Directory(); directory.Name = directoryName; _directoriesList.Add(directory); // why we don't use indx anywhere? indx = _directoriesList.Count - 1; } else directory = _directoriesList[indx]; ++_globalImagesCount; directory.Files.Add(filePath); }