posted on Monday, February 28, 2005 11:15 AM
by
thomasswilliams
Isolated Storage
A while ago I blogged that I discovered that attempting to write to app.config was a bad idea. The officially sanctioned solution for per-user settings is writing to the user's profile directory which is accessible in .NET by using Isolated Storage (IanG wrote a good article about this).
Up till my earlier blog post I believed that the app.config file was a good place to update settings that might be changed at runtime. I even adapted code from a Code Project article "Save and Restore User Preferences" to help me read and write settings easily, added caching, and used it in all my applications. The advantages seemed to be that the app.config file is XML, so it was easily read and written, and I knew the file would exist as it's installed with apps. But, it turns out that app.config is actually a deployment kind of file. The clincher came when I installed an app on a user's PC and found they could not write to the directory where app.config was stored...so, changes to it, especially per-user settings, should be stored using Isolated Storage.
There's a few good articles to get anyone else interested in Isolated Storage started:
I eventually settled on Rocky Lhotka's “Adventures in Visual Basic .NET: Storing User Configurations” solution which I pretty much used as-is. It takes a little bit more thought to set up than some of the other suggestions (but is strongly-typed), and having one-line Save & Restore methods is a real bonus, plus I can change the storage to INI files or the registry if I really want.