Extraction of Text File - TechRepublic
Question
August 17, 2007 at 09:31 PM
vishalluthra

Extraction of Text File

by vishalluthra . Updated 18 years, 3 months ago

Hi again! I need to write code that reads a text file. I need to be able to parse the file based on the 1st character of every line. If the character is a “1”, skip to the next line, if it’s a “2”, read every line until another “1” appears at the start of another line. The code should repeat to the end of the file. How would I modify this code to do that?

[Code]

using (StreamReader sr=new StreamReadr(“test.txt”))
{
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
Console.Read();
}
[/Code]

This discussion is locked

All Comments