예제 #1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            worker.WorkerReportsProgress = true;
            double totalFiles = 0;

            foreach (fileInfo F in info.files.Values)
            {
                if (F.Extension != ".dm")
                {
                    continue;
                }
                totalFiles++;
            }
            double doneFiles = 0;

            foreach (fileInfo F in info.files.Values)
            {
                if (F.Extension != ".dm")
                {
                    continue;
                }
                StreamReader reader = new StreamReader(F.FullPath);
                int          line   = 1;
                while (!reader.EndOfStream)
                {
                    string strLine = reader.ReadLine();
                    int    x       = strLine.IndexOf(textBox1.Text);
                    int    y       = strLine.LastIndexOf(textBox1.Text);
                    if (x >= 0)
                    {
                        lineFound n = new lineFound();
                        n.str  = textBox1.Text;
                        n.line = line;
                        n.file = F.FullPath;
                        arrStr.Add(n);
                    }
                    if (y >= 0)
                    {
                        lineFound n = new lineFound();
                        n.str  = strLine;
                        n.line = line;
                        n.file = F.FullPath;
                        arrStr.Add(n);
                    }
                    line++;
                }
                doneFiles++;
                int progress = (int)Math.Round((doneFiles / totalFiles) * 100);
                worker.ReportProgress(progress);
            }
        }
예제 #2
0
 private void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     worker.WorkerReportsProgress = true;
     double totalFiles = 0;
     foreach (fileInfo F in info.files.Values)
     {
         if (F.Extension != ".dm")
             continue;
         totalFiles++;
     }
     double doneFiles = 0;
     foreach (fileInfo F in info.files.Values)
     {
         if (F.Extension != ".dm")
             continue;
         StreamReader reader = new StreamReader(F.FullPath);
         int line = 1;
         while (!reader.EndOfStream)
         {
             string strLine = reader.ReadLine();
             int x = strLine.IndexOf(textBox1.Text);
             int y = strLine.LastIndexOf(textBox1.Text);
             if (x >= 0)
             {
                 lineFound n = new lineFound();
                 n.str = textBox1.Text;
                 n.line = line;
                 n.file = F.FullPath;
                 arrStr.Add(n);
             }
             if (y >= 0)
             {
                 lineFound n = new lineFound();
                 n.str = strLine;
                 n.line = line;
                 n.file = F.FullPath;
                 arrStr.Add(n);
             }
             line++;
         }
         doneFiles++;
         int progress = (int)Math.Round((doneFiles / totalFiles) * 100);
         worker.ReportProgress(progress);
     }
 }