I've updated the Building a better .Net Application Configuration Settings Class article and code. There have been a number of additions to the class including support for writing to external .Config files and writing to custom sections.
I've also fixed a bug that would cause the class to blow up if you didn't have rights in ASP.Net to write the file (oops!). This relates to my recent post Configuration File Settings and ASP.Net Security. Previously the class didn't check for failure in the DOM output routine which would blow up. Now the code traps any write errors but still doesn't write. I've also changed the signature to return a bool to let you know whether the write worked.
Finally I've changed the syntax for handling encryption and sections so that it is more 'natural' rather than writing a convoluted constructor. The old syntax still works, but there are now methods to specify the fields to encrypt and the section to write to. These methods can be called externally or be embedded into a custom constructor which still has to call the : base(false) to prevent the default loading of config settings before these settings are made. The article's text has been updated to reflect this info as well.
Other Posts you might also like