Hello,
I was just wondering how I would refer to a certain line in a text file. It is by using an index of some sort? here is my try:

using (StreamReader worldlist = new StreamReader("wordlist.txt"))
                            {
                                string line;
                                line = worldlist.ReadLine(count);

                                listBox1.Items.Add(line);

                            }

Unfortunately the error is "No overload for method 'ReadLine' takes '1'."
Please help?
N.

Recommended Answers

All 4 Replies

Hello,
I was just wondering how I would refer to a certain line in a text file. It is by using an index of some sort? here is my try:

using (StreamReader worldlist = new StreamReader("wordlist.txt"))
                            {
                                string line;
                                line = worldlist.ReadLine(count);

                                listBox1.Items.Add(line);

                            }

Unfortunately the error is "No overload for method 'ReadLine' takes '1'."
Please help?
N.

ans.the error occur caz ReadLine method cannt take any of the argument caz it hav to take value on the runtime
to take value on runtime ,in c#there is another procees of command line arguments

textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[0]; //line 1
      textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[1]; //line 2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.