You haven't shown any code, and your description is pretty woolly, but as of .NET 4 this would be a very easy way to do what you want:
IEnumerable<string> lines = File.ReadLines().Where(line => line != "");
Note that it won't perform any trimming, so a line with only spaces in would still be returned.
Also note that the code above doesn't read the file when you just execute that line - it will only read it when you try to iterate over lines
, and will read it again every time you iterate over lines
. If you want to read it into memory all in one go, you might want:
List<string> lines = File.ReadLines().Where(line => line != "").ToList();