CommandLineFormatter Class

Formats the executable and the arguments of a process as one command line, for display.

public static class CommandLineFormatter

Methods

NameDescription
Format(string, IEnumerable<string>)Formats an executable and its arguments as one command line, for display.

Format(string, IEnumerable<string>)

Formats an executable and its arguments as one command line, for display.

public static string Format(string executable, IEnumerable<string> arguments)

Parameters

executable string
The name or the path of the program.
arguments IEnumerable<string>
The arguments of the program.

Returns

string The executable, then each argument, separated by spaces.

Exceptions

ArgumentNullException
executable is null. - or - arguments is null.
ArgumentException
arguments holds a null item.

Remarks

An item that is empty, or that holds a space, a tab, or a double quote, is enclosed in double quotes, and each double quote in it is preceded by a backslash. Any other item is shown as it is.

The result is meant to be read by a person. No shell and no program is guaranteed to split it back into the same items, because the rules for that differ between operating systems.