I have a text file in which a particular character repeats at the start of the line after every few lines. the no. of lines in between is not fixed. I am able to find out those lines where this condition occurs. I want to read those lines in between.
using (StreamReader sr = new StreamReader(@"text file"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.StartsWith("some character"))
Because the next time, this character occurs, the code remains same. I am not able to read those lines in between
For eg.
Condition at the begining of a line
Next line
Next line
Condition at the begining of a line
Next Line
Next Line
Next Line
Next Line
Condition at the begining of a line
I have to read lines in between. The condition remains same every time. Thanks.
I assume you want to parse the text file and process all the blocks of text between conditions each time.
Basically you read each line, check for the first condition, which signals the start of a “block” and keep reading the lines until you find another condition, which signals the end of the block (and the start of another).
Wash, rinse, repeat.
A simple example: