I want to create a configuration file (text file preferred) that can be modified by user. A windows service will read from that file and behave accordingly. Can you recommend a file format for this kind of process?
What I have in my is a config file like the game config files, but could not imagine how to read from it.
My question is very similar to INI files or Registry or personal files?, but my question is different because I need to consider user editing.
3
Personally I’d use Settings, its xml based, but the real benefit is that MS have already done all the coding for you for most types (including both global settings and per user overrides), so it really simple to use. as Wyatt points out in his answer it is also possible to extend using custom configuration sections (personally I find this overkill for most configuration needs, but its nice to have available when you do have a complex configuration scenario).
Depending on how tech savvy the users are you could use Settings and allow the user to edit the xml themselves.
If the users are not tech savvy then I’d suggest you provide a GUI to allow editing anyway as otherwise you will quickly find you have support calls about corrupt config files (regardless of what format you use)
1
Writing a simple DSL in Boo is an excellent solution for this kind of problem and near-infinitely extensible as the rules get more complicated. You can even, without too much effort, give the user basic Intellisense by shamelessly reusing a bit of SharpDevelop. And you can easily validate the rules they create.
However, seriously consider providing a user interface. It’s more work on your side to develop but it’s less work later to support.
3
For .NET you might as well create your own custom configuration section. In terms of having users update it, you’d probably want to write a tool but that is relatively easy — the configuration APIs make it easy to modify the settings without writing alot of code.
If you wish to avoid XML, there are lots of options. Most of those game config files you see are lua scripts. Some other interesting options would be ruby or python — both of which have CLR implementations as IronRuby and IronPython and would be fairly straightforward to implement.
1