我需要帮助我正在实习的程序.我们的想法是检查用户登录任何PC的频率.当用户登录时,该信息将记录在文本文件中,如此格式.
01-01-2011 16:47:10-002481C218B0-WS3092-Chsbe (XP-D790PRO1)
Run Code Online (Sandbox Code Playgroud)
现在我需要搜索文本文件并(例如)在文本文件中搜索用户Chsbe的所有登录日期.
我的代码到目前为止:
private void btnZoek_Click(object sender, EventArgs e)
{
int counter = 0; string line;
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("c:\\log.txt");
while((line = file.ReadLine()) != null)
{ if ( line.Contains(txtZoek.Text) )
{
txtResult.Text = line.ToString();
}
}
file.Close();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何将包含searchterm的日志中的所有字符串返回给txtResult?