URGENT Reading from a .txt file RRS feed

  • Question

  • How would I read from line 4 and onwards?
    Is there a way to specify from which line you want to read from?
    Sunday, March 4, 2007 3:41 PM


  • Here i a snippet from a article regarding reading lines. Below is the link. I think this can be modified to do what you are asking.


    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace ReadLine
        class Program
            static void Main(string[] args)
                //Load our text file
                TextReader tr = new StreamReader("\\test.txt");

                //How many lines should be loaded?
                int NumberOfLines = 15;

                //Make our array for each line
                string[] ListLines = new string[NumberOfLines];

                //Read the number of lines and put them in the array
                for (int i = 1; i < NumberOfLines; i++)
                    ListLinesIdea = tr.ReadLine();

                //This will write the 5th line into the console
                //This will write the 1st line into the console


                // close the stream


    Best of luck,



    Sunday, March 4, 2007 4:03 PM