Hi,
I am currently writing a program to scan through some files, find a string (or preferably keywords), Print the line to a file and count how many times it occurs. However each time I test the input string using an if statement, I get a positive result as long as the file contains some sort of text.
I am new to c# so it is probably a misunderstanding of the classes I'm using but any help will be appreciated.
Thank you
Note: I am not at the stage of writing the results to a file yet, I am writing to the console for testing purposes.
Code:
using (StreamReader read = File.OpenText(file))
{
string line;
while ((line = read.ReadLine()) != null)
{
if (line.Contains("Test String")) ;
{
count++;
Console.WriteLine(count);
Console.WriteLine(line);
}
}
read.Close();
}