Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从代码C运行命令promt应用程序#_C# - Fatal编程技术网

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

C# 从代码C运行命令promt应用程序#,c#,C#,这是我的代码: var startupPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; // +\\Common System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo st

这是我的代码:

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();
路径是正确的。A要启动应用程序并设置此参数
sound 1.wav result.wav-tempo=35
。我做错了什么? startInfo的内容。参数:

"/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);

但是我现在做错了吗?

你能试着换一行吗:

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


您必须在双引号下的参数中设置路径:

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

你能告诉我们
startInfo.Arguments
的内容是什么吗?你可以先不隐藏它,这会给你一些关于错误的潜在线索。也许你应该设置一个断点,看看startupPath+@“\Common\sound”到底是什么,并检查以确保
sound.exe
实际上位于公共目录中。为什么要启动命令提示符?为什么不直接启动
声音
过程呢?斯科特,请检查我的代码。嗨,亚历山大,有人错误地编辑了我的答案。我已经重新编辑过了。请你再试一次好吗。
"/c \"C:\\SOUNDS\\New folder\\TrunscribeHelper\\Common\\sound 1.wav\" result.wav -tempo=35"