[Mono-devel-list] Arguments with spaces when starting external program through System.Diagnostics.Process

Miquel Ramírez mvorkosigan at gmail.com
Sun May 22 11:26:41 EDT 2005

You must escape also the backlashes. For instance, to invoke a program like this

$ tar -cf rock.tar This file rocks.txt

the command string in you C# program should be:

"tar -cf rock.tar This\\ file \\ rocks.txt"


On 5/22/05, Sebastian Nowozin <nowozin at gmail.com> wrote:
> Hello everybody,
> I try to use the System.Diagnostics.Process class on Debian with Mono
> 1.1.6, to execute an external program, which takes as first parameter
> an absolute pathname.  As I do not know anything about the pathname
> except that it is a valid file, it may contain spaces.
> I use Process.StartInfo.Arguments, which is of type string, to pass
> the arguments.  However, I discovered that the Mono implementation of
> the Process class seems to act like a shell in that it splits the
> arguments on whitespaces.  I tried to escape spaces using '"' and "\
> ", with no success.  (The attached program illustrates the problem.)
> Hence, my question:
> Is it possible to explicitly escape the arguments, or - alternatively
> - a way to explicitly set each argument vector on its own? (like
> argv[1], argv[2], etc.)
> Regards,
> Sebastian Nowozin
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list