Where are application settings saved?

后端 未结 4 1554
悲哀的现实
悲哀的现实 2020-12-06 23:51

I am trying to store some persistent application data so I\'ve added a setting to the project by R-Clicking on it, selecting properties, then Settings tab and manually enter

4条回答
  •  自闭症患者
    2020-12-07 00:14

    It depends on if this is a machine-level setting or a user level setting.

    For machine-level settings, the app.config file in your project only stores the original setting used for development, so that when you finish building the app and deploy it to production or deliver to your customer, that default value will be there on first install.

    When you change the value during debugging, your program is (by default) in a /bin/Debug/ folder off the root of the project. There will be another an app.config file there that includes the project as part of the file name: project.app.config. This is where your saved settings go.

    An important thing to remember here is that, by default, your app is deployed to a folder in the Program Files directory, and also that standard users, by default, don't have write access to this location. This means that application level settings can't be changed by standard users.

    For user-level settings, a similar process happens. However, there is one important difference. Instead of living in the same folder as your app, it uses your user's AppData folder instead. This means that standard users do have write access, and the ability to change the setting. However, it means finding your config file is a bit tricky, because you have to protect against two applications with the same name trying to store the config file in the same folder.

提交回复
热议问题