Posts

Showing posts with the label appsettings

Get/Set app.config values for WPF and Windows forms using C#

Image
In Windows forms developers sometimes need a place to store information like connection strings or data binding to controls. This is typically done usually under project properties by creating a setting which generates xml e.g. < userSettings >   < WindowsFormsApp1.Properties.Settings >     < setting   name = " Author "   serializeAs = " String " >       < value > Karen Payne </ value >     </ setting >   </ WindowsFormsApp1.Properties.Settings > </ userSettings > Although this works sometimes we want more control so we can have < appSettings >   < add   key = " DatabaseServer "   value = " .\SQLEXPRESS "  />   < add   key = " Catalog "   value = " NorthWind2020 "  />   < add   key = " SortColumn "   value = " CompanyName "  />...