Results 1 to 3 of 3

Thread: Save question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2014
    Posts
    31

    Save question

    I recently learned that My.Settings.Save() can save things. But where does it save the information? I found out it is not in the program itself. If I move the debug exe to another location it can't find the saved data (but storing a new data and loading that does still work). So where does the data store?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    24,033

    Re: Save question

    Application settings consumes two files: <app>.exe.config and user.config, where app is the name of your Windows Forms application. user.config is created on the client the first time your application stores user-scoped settings. <app>.exe.config, by contrast, will exist prior to deployment. So you need to deploy <app>.exe.config with your .exe file.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,130

    Re: Save question

    Further to that, the application settings file is stored in the program folder while the user config file is stored under the user's personal folder. The point of the user config file is that each user on a Windows machine can have their own settings for the app.

    When you create a setting in the project properties, application-scoped settings will be stored in the application settings file and are read-only, while user-scoped settings will have their default values stored in the application config file and their current values for each user stored in the user config file for each user. For a new user or a user who has deleted their user config file, a new user config file will be created and the default values for user-scoped settings copied from the application config file.

    Application-scoped settings are read-only because any old user should not be able to modify settings that affect every user of the application. An administrator with appropriate privileges can edit the application config file to change those settings but it is done via the Configuration system, not via My.Settings.

    It's also worth noting that, by default, My.Settings.Save will be called when your app closes. That will only fail to happen if your app crashes or the system crashes/freezes. If you're handling the application's UnhandledException event then a crash is basically impossible, even for unanticipated exceptions.

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