public string AddNewFile(string s, List<Car> list, string endPath, string path, AbstractClass rep) { list.Clear(); Console.WriteLine("Файлы :"); Info(s); Console.WriteLine("Введите значение"); if (endPath != null) { rep.CloseFile(); path = GetFile(s); rep.ReadFile(path, list); } else { do { path = Console.ReadLine(); } while (!(path.EndsWith(s))); } return path; }
//Проверка удаления файла public void CheckDeleteFile(string s, string delFile, AbstractClass method) { bool m = false; DirectoryInfo dir = new DirectoryInfo(@"C:\Users\Vlad\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug"); FileInfo[] bmpfiles = dir.GetFiles("*" + s); if (delFile.EndsWith(s)) { while(m) { foreach (FileInfo f in bmpfiles) { if (delFile == f.Name) { m = false; } } if (m == true) { Console.WriteLine("Вы ввели неправильно название файла, повторите"); delFile = Console.ReadLine(); } } method.CloseFile(); } }