locked
streamreader reading blank line RRS feed

  • Question

  •  
    hi
    my problem is that i have a text file that reads the following

    hello

    1
    2
    3

    and im trying to read the blank line under the "hello"
    but i wrote the following code below and it aint working?

    string str;  
     
                try  
                {  
                      
                    StreamReader sr = new StreamReader(@"Testing.txt");  
     
                    while ((str = sr.ReadLine()) != null)  
                    {  
                        if(str.Equals("\n")){  
     
                        Console.WriteLine("it worked");  
                        break;  
     
                        }  
     
                        else  
                        Console.WriteLine(str);  
                    }  
     
                    sr.Close();  
     
                }  
                catch  
                {  
                    Console.Write("failed");  
                }  
     
                Console.Read();  
     
    Wednesday, October 15, 2008 1:05 AM

Answers

All replies