2014-02-26 66 views

回答

1

可以使用Process類來實現這一目標:

using (p = new System.Diagnostics.Process()) 
{ 
    p.StartInfo.FileName = "PathTo.exe"; 
    // Provide command line argument 
    p.StartInfo.Arguments = "arg1 arg2 arg3 \"Arg with whitespace\""; 
    // You can also try to set the working directory when you run the process 
    p.UseShellExecute = false; 
    p.WorkingDirectory = @"C:\OutputDirectory"; 
    p.Start(); 
    // In case you want to wait for the process to exit 
    p.WaitForExit(); 
} 
+0

您好,感謝您的回答。 Bt我已經得到了通過參數後的exe文件的窗口。我只是不知道如何重定向exe的輸出到一個新的目錄。 –

+0

@AnanyaMalik:這取決於你正在調用的exe文件。也許你可以在參數中改變它,也許你可以通過設置工作目錄來解決它。我已經更新了示例。 – Markus

+0

Thnx很多。我得到它的工作.. :) –