Results 1 to 3 of 3

Thread: App.Config file not storing values

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2015
    Posts
    58

    App.Config file not storing values

    I have an Application which has 4 user settings.

    However I have a couple problems.
    The first is that the Config file doesn't show the correct value for the setting. In the file, it is listed as "7000" and doesn't change. However, when I open the form, edit textbox linked with the setting, then close it, the setting is saved in the control when I next open the form. Even though the changes are not reflected in the config file.

    This shows the Config settings
    This one shows the Setting that I set when I did the above steps

    Here is a pastebin of the Config file

    Thanks.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: App.Config file not storing values

    Ok... Disclaimer - I have not looked at any of the links ...

    But... here's how config files - note fileS ... plural - work...
    Settings can have multiple scopes... Machine, web, application, user ... and they load in that order - although web & app are on the same level and one or the other will load depending if it's a web app or a winform app ... with each one sucessively overlaying the previous one(s).

    I'm going to ignore the machine.config file as it has a global scale and doesn't really apply to this case.

    When you create a setting you can make it either an application scope or used scope value. Application scope settings are technically read-only, even though there is a way around that. User scoped settings are read-write.
    Initially you will have a app.exe.config file... this contains all of the Applicaiton settings and the DEFAULT user ones.... but once you change it, it gets stored in the user.config file in the user's app data directory...this is how each user comes to have their own values. If it wrote back to the app config file, everyone would have that setting.

    this is where that overlaying comes in...

    when you start you app, it takes the app.config file and loads it... then it loads the user.config file and overlays it, so that user values in the cofig file then overlay the default values ... and that is how one person gets 10 and another 700 and someone else still gets 0.

    make sense?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: App.Config file not storing values

    So what he's saying is, go digging through your AppData directory and you'll find your user.config file. It should be located in something like
    C:\Users\<username>\AppData\Local\<Company or program name>\<program name with unique suffix>\<version>\user.config

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