public List <SqlInfo> ReadSql() { var sqlFileList = new List <SqlInfo>(); if (!FolderManager.SearchFolderPaths(_root, _rootFolder).First().IsValid) { Console.WriteLine($"The folder {_rootFolder} was not found please try in another root directory."); Console.WriteLine("Pres any key to exit"); Console.ReadLine(); return(sqlFileList); } var startRoot = Path.Combine(_root, _rootFolder); var rootFolderList = FolderManager.GetFoldersList(startRoot); foreach (var folder in rootFolderList) { if (!folder.Contains(_destinationFolder)) { var workingFolders = FolderManager.SearchFolderPaths(folder, _destinationFolder).Where(nf => nf.IsValid).Select(nf => nf.Path).ToList(); if (!workingFolders.Any()) { continue; } foreach (var workingFolder in workingFolders) { sqlFileList.AddRange(GetSqlFiles(workingFolder)); } } else { sqlFileList.AddRange(GetSqlFiles(folder)); } } return(sqlFileList); }