CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    14

    Exclamation Adding information to a text file

    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??

  2. #2
    Join Date
    Feb 2002
    Location
    Atlanta, Georgia, USA
    Posts
    155

    Re: Adding information to a text file

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured