hi,
i want to know the line number of a particular string in a text file.
I want to have line number of the matching stringCode: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"); }





Reply With Quote