-4
public static void RunProcess(string FileName, string Arguments, ProcessWindowStyle WindowStyle, bool WaitforExit)
{
    MessageBox.Show("Runnig the process :- File name- " + FileName.ToString() + "argumetns- " + Arguments.ToString() + "windowStyle- " + WindowStyle.ToString() + "WaitForExit- " + WaitforExit.ToString());
    Process MyProcess = new Process();
    MyProcess.StartInfo.FileName = FileName;
    MyProcess.StartInfo.Arguments = Arguments;
    MyProcess.StartInfo.WindowStyle = WindowStyle;
    MyProcess.Start();
    if (WaitforExit)
        MyProcess.WaitForExit();
}

Here Arguments are having some spaces too.!!

Dmitry
  • 13,797
  • 6
  • 32
  • 48
DDave
  • 608
  • 6
  • 17

1 Answers1

0

If you are talking about spaces in arguments in general, then you need to wrap the arguments with double qoutes:

MyProcess.StartInfo.Arguments = "\"this argument has spaces\"";

So make sure that happens to the arguments that get passed on to your method.

Huron
  • 1,055
  • 1
  • 9
  • 16
  • So, i first need to look to my arguments if it has any spaces that need to wrap it with quotes.!!right? – DDave May 08 '14 at 12:19
  • Yes. You can choose to always use the double quotes, even without spaces, if that helps. But as soon as there are spaces in the arguments you definitely need to use the double quotes. – Huron May 08 '14 at 12:21
  • Ok...got it!Great man! – DDave May 08 '14 at 12:23
  • NB this will only cope with one argument. Also it will go wrong if teh argument (or arguments) have a double quote in them e.g. --height=6"3' – Tony Hopkinson May 08 '14 at 12:26
  • yeah, funny characters will need to be escaped properly of course, I only mentioned spaces since that was the question/problem of the OP. – Huron May 08 '14 at 12:37
  • adding double quotes to each arguments solved the issue. but for special chars how can i take care of those? – DDave May 08 '14 at 12:56