Question Locked

Extraction of Text File

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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]

2 replies

by saurabh_bhadauria

hi i am doing a job for reading a text file but i m getting exception at
(StreamReader sr=new StreamReadr("test.txt"))
'Could not find file "test.txt"'
while i m sure that file exist there....
thanks in advance

This discussion is closed to new replies.