Hi all,
I am new to c#. I am trying to read a text and find a string from that text file. I want to get the text between two particular line number . Intially i want to get two particular string's line number . then the text between these two strings needs to be copied to a new file.
I have not progressed a lot on this. Here is what i have till now
string filePath = @"d:\file.txt";
StreamReader streamReader = new StreamReader(filePath);
string text = streamReader.ReadToEnd();
streamReader.Close();
string regMatch = "Active Routes:";//string to search for inside of text file. It is case sensitive.
if (Regex.IsMatch(text, regMatch))//If the match is found in allRead
{
Console.WriteLine("found\n");
}
else
{
Console.WriteLine("not found\n");
}
First i want the line number of the matching text.