| | |
lines in a text file
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
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:
Unfortunately the error is "No overload for method 'ReadLine' takes '1'."
Please help?
N.
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:
C# Syntax (Toggle Plain Text)
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.
StreamReader.ReadLine() takes no arguments.You can hold the text file string into string then cut\split it by '\n' then refer to the index of the array returned.
Here also an example: http://msdn.microsoft.com/en-us/libr....readline.aspx
Last edited by Ramy Mahrous; Apr 26th, 2009 at 9:12 am. Reason: Example added
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
StreamReader.ReadLine()takes no arguments.
You can hold the text file string into string then cut\split it by '\n' then refer to the index of the array returned.
Here also an example: http://msdn.microsoft.com/en-us/libr....readline.aspx
Thanks, this is a great help.
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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:
C# Syntax (Toggle Plain Text)
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
0
#5 Nov 7th, 2009
C# Syntax (Toggle Plain Text)
textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[0]; //line 1 textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[1]; //line 2
![]() |
Similar Threads
- Counting lines in a text file and further operations (C++)
- Reading Lines from Text File (C)
- Script to Remove duplicate lines from a text file. (Perl)
- Newbie: problems deleting lines from text file (large) (Python)
- read-delete lines from a text file (PHP)
- how to remove a number of lines from a text file ? (Python)
- # of lines in a text file (Java)
- how do i read the last line of a text file? (Python)
- help on using StringTokenizer to read and compute multiple lines from text (Java)
Other Threads in the C# Forum
- Previous Thread: using INI(setting) file in c#
- Next Thread: Problem with ComboBox display
Views: 759 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap broadcast button buttons c# check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator path picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






