2014-05-08 38 views
-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(); 
} 

這裏參數也有一些空格。如何使用多個參數運行應用程序?

+0

究竟是什麼問題? –

+0

問題是什麼? –

+0

它拋出無效參數的錯誤。 – DDave

回答

0

如果你在談論一般的論點空格,則需要用雙qoutes包裝參數:

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

所以要確保恰好是那些獲得傳遞給你的方法的參數。

+0

所以,我首先需要看看我的論點,如果它有任何需要用引號括起來的空格。 – DDave

+0

是的。如果有幫助,您可以選擇始終使用雙引號,即使沒有空格也是如此。但只要參數中有空格,您肯定需要使用雙引號。 – Huron

+0

好吧......知道了!偉大的人! – DDave

相關問題