Where to keep config data other than config file (Windows App)?
Someone asked on Stack Overflow:
My Windows application GUI is accepting some required application configuration fields from the user. I need to store them of course, but I wanna hide these fields from the user.
- I cannot use database to store these configs.
- I want to avoid using app.config either. (No app.config encryption)
Any suggestions, Where and in which format i should store fields. (Field example is: Accepting database User credentials, Task Schedule info etc.)
I posted the following answer, which was chosen as the accepted answer and received 1 upvote:
I would use an XML file (encrypt if you feel its necessary) and use
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
to store it in the %AppData% section of the user’s file system.
Additionally, you may write a Settings class which you serialize to disk and deserialize to memory — this could save you some persistance logic with the XML namespace.
Notable comments
Nate (0 upvotes): No, that is exactly the point of AppData — it will find a place the current user has read/write access to.
Originally posted on Stack Overflow — 1 upvotes (accepted answer). Licensed under CC BY-SA.