Click to See Complete Forum and Search --> : Adding information to a text file


bboy_romeo
December 4th, 2004, 02:43 PM
I want to add information from different txtboxes into my file that i've created, so later I can view the updated information in my listbox.

I've tried just using lstrecords.items.add(txtfirstname.text)
lstrecords.items.add(txtlastname.text)
lstrecords.items.add(txtmajor.text)
and so forth, but it only adds to the listbox i've created
I want it to add to the text file, and not have it display back as

Tom
Bernard
T122
7.0

I want it to display back in the text file as one line
Tom Bernard T122 7.0

Can someone help me with doing this??

soumya_bhatta
December 4th, 2004, 09:59 PM
First make a single string variable which should hold the entire string:
"Tom Bernard T122 7.0"

After that write this string into a text file. For this you have to use "StreamWriter" class from .Net.

For reading back from the text file, you can use the "StreamReader" class.

These are all part of System.IO namespace.