944,156 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1612
  • C# RSS
Apr 26th, 2009
0

lines in a text file

Expand Post »
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)
  1. using (StreamReader worldlist = new StreamReader("wordlist.txt"))
  2. {
  3. string line;
  4. line = worldlist.ReadLine(count);
  5.  
  6. listBox1.Items.Add(line);
  7.  
  8. }

Unfortunately the error is "No overload for method 'ReadLine' takes '1'."
Please help?
N.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nimbusania is offline Offline
3 posts
since Apr 2009
Apr 26th, 2009
0

Re: lines in a text file

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
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Apr 26th, 2009
0

Re: lines in a text file

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nimbusania is offline Offline
3 posts
since Apr 2009
Nov 7th, 2009
0

ankur bhutani

Click to Expand / Collapse  Quote originally posted by nimbusania ...
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)
  1. using (StreamReader worldlist = new StreamReader("wordlist.txt"))
  2. {
  3. string line;
  4. line = worldlist.ReadLine(count);
  5.  
  6. listBox1.Items.Add(line);
  7.  
  8. }

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ankurbhutani is offline Offline
1 posts
since Oct 2009
Nov 7th, 2009
0
Re: lines in a text file
C# Syntax (Toggle Plain Text)
  1. textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[0]; //line 1
  2. textBox1.Text = System.IO.File.ReadAllLines(@"C:\file.txt")[1]; //line 2
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: using INI(setting) file in c#
Next Thread in C# Forum Timeline: Problem with ComboBox display





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC