Read Text File Line by Line in C#

I happened to work on files. My condition to read the file line by line. Here is a small piece of code to read the file line by line.... I got the snippet from Microsoft BOL.

private void btnBrowse_Click(object sender, EventArgs e)
        {
            int counter = 0;
            string line;
            rtb_filecontent.Text = "";
            // Read the file and display it line by line.
            System.IO.StreamReader file =
               new System.IO.StreamReader("D:\\1.txt");
            this.listBox1.TopIndex = 0;
            while ((line = file.ReadLine()) != null)
            {
               // rtb_filecontent.Text = rtb_filecontent.Text + "\n" + line;
                listBox1.Items.Add(line);
                //rtb_filecontent.AutoScrollOffset = new Point(rtb_filecontent.AutoScrollOffset.Y, 10);
                Thread.Sleep(200);
                counter++;
            }
            file.Close();            
        }
Ebook Download
View all
Learn
View all