![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2008
Posts: 5
Rep Power: 0
![]() |
Readline
Hi,
I always get stuck when I try to do readlines. I am writing a program that is suppose to open a file when you click on open file, then the file that it opens should read the first part and do a item add to a combo box. Any help would be appreciated. If you need more info please let me know. Thanks, Rachel |
|
|
|
|
|
#2 |
|
11 years old
Join Date: Nov 2007
Posts: 79
Rep Power: 1
![]() |
Re: Readline
System.IO.File.ReadAllLines("./myfile.ext")[0]
Read the .NET API docs, and perhaps bookmark the page: http://msdn2.microsoft.com/en-us/library/ms229335.aspx
__________________
iload_0 iconst_1 ishl or iload_0 iconst_2 idiv or iload_0 iconst_2 iconst_1 imul idiv [1] & [2] use the smallest stack size |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2008
Posts: 5
Rep Power: 0
![]() |
Re: Readline
Thank you
![]() Yes, I understand it could be done this way...but how would I do it if I don't know the name of the file? The user has to pick the file and when they hit "Ok" the file should be read. Rachel |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
Re: Readline
You'd need to use an open file dialog box.
MSDN have an excellent tutorial video series on this sort of stuff. Go to this URL: http://msdn2.microsoft.com/en-us/vstudio/aa700732.aspx and then scroll down to the bottom of the page. From memory, dialog controls are covered in Lesson 4. Regards, Matt. I |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2008
Posts: 5
Rep Power: 0
![]() |
Re: Readline
Right. I am using an open dialog box. But once the file is opened I don't know how to read the file to put the first part of the text into a combo box. The code should read the text line by line and put only the first part into a combo box so that when the arrow is selected you should see a choice of 100, 200, 300, etc...
I'll go to the link. I have tried these tutorials, but they do not go into great detail. I hope this one does. Thanks, Rachel |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
|
Re: Readline
The other thing that you could benefit from is probably getting a good book. There are loads around and if you want detail are probably much better than most tutorials on the internet.
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Dec 2005
Posts: 118
Rep Power: 0
![]() |
Re: Readline
Instead of hard coding the filename (
System.IO.File.ReadAllLines("./myfile.ext")[0]) just use the dialog's filename property after displaying it. E.g.if(openFileDialog1.ShowDialog() == DialogResult.OK ) comboBox1.Text = System.IO.File.ReadAllLines(openFileDialog1.FileName)[0] |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Update IdTCPSDerver in a DLL | sggaunt | Delphi | 0 | Mar 13th, 2007 11:56 AM |
| Client/server programming question... | GoO | Java | 3 | Aug 27th, 2005 5:18 AM |