Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }