Fast way to read from a line to another in a textfile?

  • Thread starter Thread starter Peter Hartlén
  • Start date Start date
P

Peter Hartlén

Hi!

Which is the best (fast but faily simple) way to read a section of a
textfile if you know which lines to start and stop?

This is what I am thinking about using, is there a better way?

rowStart = 10;
iLineNum = 1;
while( iLineNum < rowStart )

{

if( sr.ReadLine() == null )

break;

iLineNum++;

}



Thank,

Peter
 
Forgot the data processing...

string strLine;
int rowStart = 10;
int iLineNum = 1;

while( iLineNum < rowStart )
{
if( sr.ReadLine() == null )
break;
iLineNum++;
}

while( (strLine = sr.ReadLine()) != null )
{
if( iLineNum >= rowStop )
break;

... process file line data ...

iLineNum++;
}
 
Back
Top