private void UpdateFiles() { if (Directory.Exists(SourcePath)) { Files.Clear(); var filePathes = Directory.GetFiles(SourcePath, "*", FlattenFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList(); foreach (var item in filePathes.Select(f => FileViewModel.FromPath(f))) { Files.Add(item); if (!Extensions.Contains(item.Extension)) { Extensions.Add(item.Extension); } } for (int i = Extensions.Count - 1; i >= 0; --i) { if (!Files.Any(f => f.Extension == Extensions[i])) { Extensions.Remove(Extensions[i]); } } } }