views:

51

answers:

1

I think this is what the asker of this question is getting at, but its hard to tell and there's no accepted answer...

I have a C# app built using visual studios application settings. A really useful feature would be the ability to export the settings in one file. Similarly it would be useful to be able to import configuration files exported by another instance.

I guess this would ordinarily be a matter of copying and pasting the file they're stored in, but my users won't be savvy enough for that sort of thing, so I'd like to do it through menus and dialogues.

To complicate matters, I had to add my own settings class in addition to Properties.Settings (the visual studio default) and I'd like the generated file to be a merge of the two sets of options. (To confuse matters further, I'm not sure where the custom settings file is being saved, but that's a separate question methinks...)

So to recap:

  1. Where is my custom settings class likely to save it's XML?
  2. How would I go about merging the two files?
  3. On import, how could I split them?
+2  A: 

I'm going to be a bit blunt about this. The .NET framework design is overall rather excellent. Easy to learn, few surprises, no fat. But not everything is great. System.Configuration has a very high suck factor. Between an absurdly complicated object model and an implementation that was paralyzed by security concerns, it inevitably becomes a PITA when you try to extend it beyond the point-and-click settings designer.

Just don't go there. Using XML serialization to load/save your own configuration class(es) is a wholeheckofalot easier than battling that borked design.

Hans Passant
System.Configuration is especially fun when you're working with class libraries that need their own configurations.
Mark H
Thanks Hans, thinking about it, storing settings shouldn't be that hard, right? I mean, a class with lots of properties and methods for saving and loading would do the same thing. Not sure why I thought it had to be so magical...
Tom Wright