从代码C#运行命令promt应用程序

时间:2015-06-02 14:05:42

标签: c#

这是我的代码:

var startupPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; // +\\Common

            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments ="/c " + startupPath + @"\Common\sound 1.wav result.wav -tempo=35";
            process.StartInfo = startInfo;
            process.Start();

Pathes是正确的。想要启动应用程序并设置此参数sound 1.wav result.wav -tempo=35。我究竟做错了什么? startInfo.Arguments的内容:

"/c C:\\SOUNDS\\New folder\\TrunscribeHelper\\Common\\sound 1.wav result.wav -tempo=35"

我试图直接启动它:

ProcessStartInfo startInfo = new ProcessStartInfo(string.Concat(startupPath + @"\Common", "\\", "sound.exe"));
            startInfo.Arguments = "1.wav result.wav -tempo=35";
            startInfo.UseShellExecute = false;
            System.Diagnostics.Process.Start(startInfo);

但我现在做错了吗?

2 个答案:

答案 0 :(得分:0)

您可以尝试更改此行:

startInfo.Arguments ="/c " + startupPath + @"\Common\sound 1.wav result.wav -tempo=35";

startInfo.Arguments ="/c \"" + startupPath + @"\Common\sound"" 1.wav result.wav -tempo=35";

答案 1 :(得分:0)

你必须在双引号下的args中设置你的路径:

"/c \"C:\\SOUNDS\\New folder\\TrunscribeHelper\\Common\\sound 1.wav\" result.wav -tempo=35"