Seeking for a line i a text file
问题 I need some assistance, I am writing a method to read a text file, and if any exception occurs I append a line to the text file. e.g " ** " So what I need to know is how can I check for that specific line of text in the text file without reading every line of the text file, like a peek method or something. Any help would be appreciated. Thanks in advance. 回答1: You can use File.ReadLines in combination with Any: bool isExcFile = System.IO.File.ReadLines(path).Any(l => l == "**"); The ReadLines