I need help with the program that I create on my internship. The idea is to check how often the user logs on to any PC. When a user logs in, this information is recorded in a text file, for example, in this format.
01-01-2011 16:47:10-002481C218B0-WS3092-Chsbe (XP-D790PRO1)
Now I need to search for a text file and (for example) search for a text file for all login dates for the user Chsbe.
My code is:
private void btnZoek_Click(object sender, EventArgs e)
{
int counter = 0; string 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();
}
My question is: how do I return all log lines containing searchterm to txtResult?
source
share