i have text file and read it using stream reader, when my file is having empty line along with data, it does not read any thing. how to remove the empty line using C#.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, you should use the method “ReadLine()” from the StreamReader in a loop. When you receive an empty line, simply check if the string obtained from ReadLine() is empty. If it is, ignore the line.
Try something like: