Question: Is there a function in .NET (or PInvokable) that would prepare a command line (in the shape of one string); from a IEnumerable
of strings.
That would be the equivalent of python's subproces.list2cmdline
, but in .NET.
And it would be the reverse of Win32's CommandLineToArgvW.
As a sketch, it could probably be grossly approximated by:
static public string List2CmdLine(IEnumerable<string> args)
{
return string.Join(" ", args.Select((s) => "\"" + s + "\"")))
}
details:
python's subprocess.list2cmdline
documentation states that what they do, goes by respecting the rules of the Windows C Runtime.
I imagine they speak of the need of quotes around arguments which contains spaces, and escaping the quotes inside arguments.