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#.
解决方案
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:
StreamReader input = new StreamReader("...");
String line = null;
do
{
line = input.ReadLine();
if (line == null)
{
return;
}
if (line == String.Empty)
{
continue;
}
// Here you process the non-empty line
} while (true);