public void Init(string dir_path) { if (Directory.Exists(dir_path)) { bool flag = true; foreach (MyFolder folder in FolderList) { if (dir_path == folder.Path) { flag = false; Console.WriteLine("Директория уже отслеживается"); return; } } if (flag == true) { ActiveDir = new MyFolder() { Path = dir_path }; ActiveDir.InitList(); FolderList.Add(ActiveDir); Console.WriteLine("Директория добавлена"); } } else { Console.WriteLine("The folder didn't found"); } }
public void Apply() { List <string> list = new List <string>(); foreach (MyFile file in ActiveDir.filelist) { if (file.Label == "<-- removed") { list.Add(file.Name); } } ActiveDir.filelist.Clear(); ActiveDir.InitList(list.ToArray()); Console.WriteLine("Все изменения сохранены"); /*int i = 0; * foreach (MyFile file in ActiveDir.filelist) * { * i++; * foreach(string s in list) * { * if (file.Name==s) * { * ActiveDir.filelist.RemoveAt(i); * } * } * }*/ }