Oct 19, 2007 / .net,software
Handy .NET Console Parameter Parsing

Oh, I recently discovered that .NET gives us a useful library for parsing parameters in a .NET console app.

First, add a reference to System.Configuration.Install to your Console project. Then, you can work with it to parse params quite easily in this format:

c:\> example.exe cmd=loaddata folder="c:\my data" blah=xyz

Check out some example code to see how to use the library. It's quite neat!

I personally prefer this format...

c:\> example.exe --cmd loaddata --folder "c:\my data" --blah xyz

...which System.Configuration.Install doesn't support unfortunately. If anyone knows a way of handlnig this easily, then please let me know.


You may also like...