Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 1st, 2008, 3:22 AM   #1
RachelHelps
Newbie
 
Join Date: Jan 2008
Posts: 5
Rep Power: 0 RachelHelps is on a distinguished road
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
RachelHelps is offline   Reply With Quote
Old Jan 1st, 2008, 11:10 AM   #2
null_ptr0
11 years old
 
Join Date: Nov 2007
Posts: 79
Rep Power: 1 null_ptr0 is on a distinguished road
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
null_ptr0 is offline   Reply With Quote
Old Jan 1st, 2008, 11:17 AM   #3
RachelHelps
Newbie
 
Join Date: Jan 2008
Posts: 5
Rep Power: 0 RachelHelps is on a distinguished road
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
RachelHelps is offline   Reply With Quote
Old Jan 1st, 2008, 11:57 AM   #4
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
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
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Jan 1st, 2008, 12:07 PM   #5
RachelHelps
Newbie
 
Join Date: Jan 2008
Posts: 5
Rep Power: 0 RachelHelps is on a distinguished road
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
RachelHelps is offline   Reply With Quote
Old Jan 1st, 2008, 12:58 PM   #6
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
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.
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Jan 2nd, 2008, 3:15 AM   #7
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
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]
Klipt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:39 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC