none
streamreader line number RRS feed

  • Question

  • Is there anyway to tell streamreader to start at a line number and stop and a line number. I know the range I want it to search in but not sure if you can or not.
    Alan
    Sunday, October 24, 2010 10:26 AM

Answers

  • If all the lines are exactly the same length, you can skip to a specific offset in the file directly. If not, you will either have to build an index or loop through line by line.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Marked as answer by anaylor01 Friday, October 29, 2010 4:07 PM
    Sunday, October 24, 2010 1:31 PM

All replies

  • No; you'll have to loop and count the lines.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    Sunday, October 24, 2010 10:51 AM
  • I have a file of about 18,000 lines. Each line has an ID number.  I have the 18,000 lines broken down into about 10 groups by ordered ID numbers.  Instead of looking for the id value by looping through the entire file I would like to look for the id in just a specified amount of lines. So say I was looking for ID number 2323 I would want to look only in the lines of 1000-2500 of group 2. Would it be easier and quicker to create 10 different files?


    Alan
    Sunday, October 24, 2010 11:24 AM
  • If all the lines are exactly the same length, you can skip to a specific offset in the file directly. If not, you will either have to build an index or loop through line by line.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Marked as answer by anaylor01 Friday, October 29, 2010 4:07 PM
    Sunday, October 24, 2010 1:31 PM