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"