What is the best way to go about reading and writing simple configuration data like we used to use App.config and Web.config <appsettings />
available through ConfigurationManager
before, for use within your Windows 8 / Windows RT / Windows Store / Windows Modern UI App?
LocalSettings
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localsettings
OR
RoamingSettings
The main difference is that RoamingSettings will be saved to the cloud and thus, can be transferred across different devices for the same user profile. LocalSettings is device-specific.
-
1Akinwale, I have received three very good answers, but given this to you to boost your rep, thanks for the response! – GONeale Oct 13 '12 at 11:56
Metro apps don't have exact equivalent of app.config/web.config.
Instead you should use package.appxmanifest to configure windows store specific values.
For local settings you should use ApplicationData api.
If you want to configure application after it is deployed you could simply load remote xml or json file at application start up.
In addition to the technical answers above its important to understand why there is no config file for these apps.
WinRT/Windows store apps are client applications so unlike your ASP.NET applications that run on the server and require admin configuration changes, end users are not expected to tinker with these changes (SQL connection, timeouts, appSettings you name it) hence there is no need for such a config file for these apps,
Hope it makes sense
-
13.config files were not exclusive to web applications, so I have no idea what your answer is in reference to. – Justin Skiles Oct 15 '12 at 21:49
-
2Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Aug 12 '13 at 10:58