This project is read-only.
1

Closed

CommandLineParser cannot handle Application path

description

The commandline parser cannot handle the first argument when Environment.GetCommandLineArgs() is used, which is always the application path or String.Empty. It always throws an exception even without any arguments supplied by the user.
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx See Remarks.
Closed Feb 10, 2011 at 3:48 PM by ivom

comments

alexisr wrote Sep 15, 2009 at 12:24 AM

Hi Overlord123, Thanks for reporting the follow-up issue. This is technically by design; the correct approach in this scenario is to use the IEnumerable<T>.Skip(int) extension method. Environment.GetCommandLineArgs.Skip(1) will return the sequence, skipping the first element which is not a key/value pair.

I hope that helps! I'll leave this open so you can comment further if you like.

Alexis

Overlord123 wrote Sep 15, 2009 at 9:14 AM

Maybe you could add a parameter to just skip a command arg if it is not a Key/Value pair instead of throwing an exception, something like CommandLineDictionary.FromArguments(IEnumerable<string> arguments, bool skipOnError)?

wrote Feb 10, 2011 at 3:48 PM

wrote Feb 14, 2013 at 9:08 PM

wrote May 16, 2013 at 11:02 AM