搜索多个富文本文件很慢

时间:2013-10-16 00:23:30

标签: c# c#-4.0 rtf

我正在制作一个程序来搜索多个* .RTF文件(大约1200个文件)中的用户定义字符串。所有文件都保存在我的计算机上的目录中。到目前为止,我可以使用下面的代码轻松搜索一个文件,但是当我尝试在所有文件上运行它时,完成搜索大约需要3分钟。任何人都可以用更好的搜索算法帮助我吗?

lookup = this.textBox1.Text.ToString();
MatchCollection matches = Regex.Matches(richTextBox1.Text, lookup);

foreach (Match match in matches)
{
    richTextBox1.Select(match.Index, match.Length);
    richTextBox1.SelectionColor = System.Drawing.Color.Red;
}

0 个答案:

没有答案