Property CommandLine
CommandLine
Gets the raw unparsed command line (or as close to it as is possible for the given runtime/platform
Declaration
public static string CommandLine { get; }
Property Value
public static string CommandLine { get; }
String |
Remarks
On Desktop .NET 4.7 and earlier CommandLine provides the full command line without any
funky escape character processing. But the args passed to main or returned from GetCommandLineArgs()
have extra escape character processing. This extra processing is very problematic as it is unique to .NET apps
(C and C++ apps don't have this). If the command line foo.exe "abc\de f\"
is processed with escaping then the
result the app see is abc\de f"
(Note the inclusion of the trailing quote character), which is clearly not the
path the user intended to provide. This has always been an annoyance for .NET developers but was easily worked around
by not using the args to Main() and instead getting at the full args via Environment.CommandLine and parsing that using
whatever rules the app wants to support for args.
Unfortunately, with .NET Core things behave very differently. CommandLine is no longer the unprocessed command line and instead it is effectively a space delimited join of Environment.GetCommandLineArgs(). Meaning that is has all the .NET Specific escaping applied and there is no platform independent means of getting at the unprocessed args.
Thus, this implementation is forced to implement the only viable cross platform approach by doing a space delimited join of GetCommandLineArgs() with all it's wonky escaping rules.