The Last Configuration Section Handler I'll Ever Need

I'm sure someone, somewhere has already written this, but I figured it out on my own today, and it's just too cool not to share. Basically, it's a bit of code that lets me store objects in my application of web configuration file, and all I have to do is write the type that holds the values.

[CraigBlog]

Read the story and get the code
[ScottW's Blog]

Very cool. I feel so dumb for not thinking of this a long time ago. ehhh..

This is indeed very cool now we just need to implement a configuration/setting file that can read and write user settings to an XML file using this method.  I guess I don't fully understand why they didn't give the ablility to read and write config files through the System.Configuration namespace. 

1 Comment

  • Yeah, you're right on as far as XmlSerializer being the way (IMO) to read/write settings. Hell, you're going to put it in objects anyway (most likely). Might as well let someone else do the hard work.





    As far as Isolated Storage goes, I've heard some people complain that it has a bug related to long file names.


    The way it's implemented apparently causes it to fail sometimes.





    That said, it's trivial to use Environment.GetFolderPath to retrieve one of the user-specific directories and store your information there. I've done this in some software I've written to great effect - it's sooo easy to just add a field to a class, edit the XML file and voila - new setting in your app. :)

Comments have been disabled for this content.