Configuration files for Windows Forms Applications
Since I know I'll run across this again ...
In my iTunes Playlists to Xml application I wanted to allow users the ability to persist their name across sessions. The supported method seems to be using application configuration files; in my case, something like iTunesApplication.exe.config. However, try as I could, I just couldn't find anything solid on how to create the configuration file.
First, I had to add a reference to "System.configuration" (in References). I'm still baffled on why you sometimes need to add a reference, and other times you can just add it to the top of the code-behind file.
Once that was done using System.Configuration; worked and I was able to use Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);.
Next an "Application Configuration File" needed to be added, called app.config, and an appSettings element added within. Adding add elements with key and value attributes was the final step.
Now building the application resulted in an iTunesApplication.exe.config file being created, and my config checks working as expected.
- Review: Empires of EVE: A History of the Great Wars of EVE Online
- Review: Ghost in the Shell README: 1995-2017
- Review: Fitbit Charge 2 Bands,Fitbit Bands Milanese Loop Stainless Steel Metal Replacement Bracelet Strap, Wristbands Accessories for Charge 2 with Stronger Magnetic Clasp
- Review: Wickedly Prime Organic Roasted Seaweed Snacks, Korean Kalbi
- Review: 5-Minute Dungeon
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.