Lines with Tabs only when Reading File

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
Given a File read [using StreamReader (sR)] that contains many lines of information.

Example of File [test.txt]:
(TAB HERE)
Val1 Name1 Des1
Val2 Name2 Des2
Val3 Name3 Des3

Note that the 1st line has a TAB [it is not a blank line] and thus line.length != 0.
BUT seeing as there is no data I need my code to skip those lines also, currently it will see it has a line with data and exit with an error because it cannot find info (there is actually no information).

Code:
:
while(sR.Peek() != -1)
{
 line = sR.ReadLine();
 if (line.Length != 0)
 {
	… do work on line …
 }
}

How could I have the code skip lines that start/end with only a TAB character?
Note that some lines could have a TAB it in [which is OK], only those that ONLY have a Tab as first/last character need to be omitted [they are used to indicate a new section of the file which is of no consequence to me]
 
Back
Top