/// <summary>Finds the given text and pattern in the given file.</summary>
        /// <param name="file">The file to look in</param>
        private FileFindInfo FindInFile(FileInfo file)
        {
            StreamReader sr = new StreamReader(file.FullName);
            string       line;
            int          lineNum = 1;
            FileFindInfo ffi     = new FileFindInfo(file.FullName);

            while ((line = sr.ReadLine()) != null)
            {
                Match m = _regex.Match(line);
                if (m.Success)
                {
                    ffi.Infos.Add(new FindInfo(m.Index, lineNum, line, m.ToString()));
                }
                lineNum++;
            }

            return(ffi);
        }
        /// <summary>Find the entered text and pattern in all files in the provided directory.</summary>
        public List <FileFindInfo> FindInFiles(string ftext, string directory, string patterns, bool subdirs)
        {
            int num = 0;
            List <FileFindInfo> results = new List <FileFindInfo>();

            DirectoryInfo dirInfo = new DirectoryInfo(directory);

            string[] apatterns = patterns.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string pattern in apatterns)
            {
                foreach (FileInfo file in dirInfo.GetFiles(pattern.Trim(), SearchOption.AllDirectories))
                {
                    FileFindInfo ffi = FindInFile(file);
                    num += ffi.Infos.Count();
                    results.Add(ffi);
                }
            }

            return(results);
        }
        /// <summary>Finds the given text and pattern in the given file.</summary>
        /// <param name="file">The file to look in</param>
        private FileFindInfo FindInFile(FileInfo file)
        {
            StreamReader sr = new StreamReader(file.FullName);
            string line;
            int lineNum = 1;
            FileFindInfo ffi = new FileFindInfo(file.FullName);

            while ((line = sr.ReadLine()) != null)
            {
                Match m = _regex.Match(line);
                if (m.Success)
                {
                    ffi.Infos.Add(new FindInfo(m.Index, lineNum, line, m.ToString()));
                }
                lineNum++;
            }

            return ffi;
        }