Please help (saveing/opening data)

I have this form that allows a user to enter information about him/herself by entering text and checking check boxes. What I need is a way to:
1) Save all the input (text and cheked boxes) to a file

2) Have the user be able to open the file and it display all the information saved from the previous form and display that information in the right spot (text in the correct text box and the right check boxes checked)

I've looked and havn't been able to find anything yet on doing that (maybe not looking in the right place). Any help or points in the right direction to doing something like this would be so appreciated as I am new to C#. Thanks!


Answer this question

Please help (saveing/opening data)

  • Shima20

    Here's a "point in the right direction":

    You should look into the Settings object that is automagically created for you by the IDE as part of a new project.




  • fabianlopez

    Do a search on serializing class data.  I would create a class to hold your form data.  When the user clicks save you would save the settings to the data object and then serialize that object to an xml file.  When the user opens the file you just reverse the process.

    Here is a very simply example of serializing a object

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/cscon/html/vclrfcodewritingclassdatatoxmlfilevisualc.asp




  • cbretana

    There's several ways to accomplish what you want, the first that comes to the top of my mind is the following.

    1) for the txt file aspect you would imbed code into your file that would simply act on an if-condition where: if the box is checked then create a streamwriter and write to a file "<clientname>.txt". Pretty simple to do goto msdn.microsoft.com and do a search for writing to file <language of choice>.

    2) Storing information for future display: I would create a data table which contained the appropiate fields (address, phone #, etc). So using the bool to determine if the boxed was checked I would add that information to a session object or a string array and when button submit was clicked I would pass the information into the data table, to be retrieved at your leisure using the cutomer name as the identifier.

    I didn't include any code in this solution because your question seemed to be more idea oriented. I would read up on database driven pages as well as outputting to a file. If you have any specific question after reading up on those topics please post them.

  • Phil_

  • devjam

    That helped some, thanks. But really what I am looking for is this form takes in the customer name, address, phone # and then has check boxes for difrent options that the customer wants. What I need is a way to store all that information to a file (.txt file or something) and then be able to have the program bring that saved information back up into the windows forum and display it in the appropiate text boxes and such.

  • MikeOzz

    Hi,

    are you looking for a small xml database

  • Please help (saveing/opening data)