Question How to store data


New member
Jun 17, 2009
Programming Experience
HI all,
I want to store some information of the form in such a way that if the user quit/exit the application it stores the information. When user runs the application next time the information should be available to him. It also involve the restart of the computer. The application is in 3.5 framework.
The one way that i can think of using flat files and encrypted data, but i can not do this. I do not to store any kind of data on client side and I can not store this information on server side. The problem is of getting client machine information and storing it on server.
Help me with a solution. I know it can be done.
Thanks in advance.


Well-known member
Jul 24, 2009
Programming Experience
Take a look at Application Settings particularly the section Creating Application Settings at Design Time which will tell you, or at least link to, how to store and restore Form.Size, Form.Location and the like.

The section below Using Custom Settings Files might help if the above gives you problems.

Hope this helps. :)


Well-known member
Aug 23, 2005
Programming Experience
I like flat files the best for simple data. This way a seperate file can be created for each individual user. Is there a limiting factor that you "can not do this" or do you just not know how? Storing it to a centralized database is also an option but again you mention not being able to do this....

Application Settings seems to be another option but may may not be as flexible as needed. The settings are then saved per application level and there may be multiple users per application workstation and/or the possibility of the application running from a shared network drive.


Well-known member
Jul 24, 2009
Programming Experience
ApplicationSettings is badly named as it deals with both Application-wide and per-user settings.

The code snippet below is the *.exe.config file from an application on my machine.

I have highlighted a section in red.
Note that the node is 'usersettings' and this part will be stored for each user.
Where it is stored depends on how the network is set up. It uses Local Settings\Application Data on my standalone. This is governed by the Environment.SpecialFolder enumeration, the first three members are of interest here, and as I say how your network is set up.

I created this section in the *.config file with the following steps
1) Select Form in designer (could have selected a Button, Panel or whatever)
2) Under (ApplicationSettings), in the Property Grid, click the ellipsis on (PropertyBinding)
3) Select the property required from the Dialog that appears and click the drop-down, then click the (New...) link.
4) In the Dialog that appears give the setting a name and you can choose whether it is scoped for user or application.
5) OK your way out.

<?xml version="1.0" encoding="utf-8" ?>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="TelephoneNumberWordGenerator.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
            <add name="DefaultSwitch" value="Information" />
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
[B][COLOR="Red"]   <userSettings>
            <setting name="MainformBorder" serializeAs="String">

Do a small test for yourself. Either with an existing app or create a very simple one specially for the test. Create one or two user scoped settings (say Form.Size and Form.Location). Then have two users run the app, one user uses left and tall, the other right and wide. Close the app and restart it. They should both get what they set before closing.

So the solution could be to do as above for applicable settings and use your flat file methodology for whatever doesn't fit. However bear in mind that you can use the My.Settings for those parts too, where you can also elect for user or application scoping.

Hope this helps. :)
Top Bottom