public void Find(List <string> files, string TheWord) { int allresult = 0; foreach (string file in files) { CanBeOpen canBeOpen = FormatIs(file); if (canBeOpen.TakeCanI()) { WriteInFile("Start reading file: " + file, true); answer answ = ToOpener(file, canBeOpen.TakeFormat(), TheWord); if (answ.ResultCount() == 0) { WriteInFile("result not found.", false); } else { allresult += answ.ResultCount(); WriteInFile("found " + answ.ResultCount().ToString() + " results", false); foreach (var result in answ.AllResultsData()) { WriteInFile(result, true); } } } else { WriteInFile("File have wrong format: " + file, true); } WriteInFile("", true); } }
private CanBeOpen FormatIs(string path) { CanBeOpen canBeOpen = new CanBeOpen(); string format = Path.GetExtension(path); if (acceptFormats.Contains(format)) { canBeOpen.AddData(true, format); } else { canBeOpen.AddData(false); } return(canBeOpen); }
public void Find(List <string> files, string TheWord, string path) { int allresult = 0; WriteInFile("Find:" + TheWord, true); WriteInFile("Source:" + path, true); foreach (string file in files) { CanBeOpen canBeOpen = FormatIs(file); if (canBeOpen.TakeCanI()) { answer answ = ToOpener(file, canBeOpen.TakeFormat(), TheWord); if (answ.ResultCount() == 0) { //WriteInFile("result not found.", false); } else { WriteInFile("-----", true); WriteInFile("In file: " + file.Substring(path.Length), true); allresult += answ.ResultCount(); //WriteInFile("found " + answ.ResultCount().ToString() + " results", false); foreach (var result in answ.AllResultsData()) { WriteInFile(result, true); } WriteInFile("", true); } } else { //WriteInFile("File have wrong format: " + file, true); } //WriteInFile("", true); } WriteInFile("Results:" + allresult, true); }