本文介绍了的Process.Start()的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做下面的命令进入dos它会正常工作

when i do the following command into dos it will work fine

ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi

当我尝试使用C#过程类,无参数,它加载的ffmpeg在控制台窗口中,然后自败像往常一样。然而,当我尝试使用我上面做的,格式化的一模一样的说法......这是行不通的! ffmpeg的仍然加载,但由于控制台窗口关闭如此之快,我不能确定哪些错误是:/

When I try to use the process class in c#, without the arguments, it loads ffmpeg in a console window then dissapears like usual. However, when I try to use the argument as I do above, formatted exactly the same...it doesn't work! ffmpeg still loads, however since the console window closes so fast I cannot determine what the error is :/

Process ffmpeg = new Process();
ffmpeg.StartInfo.FileName = path + "//" + "ffmpeg.exe";
ffmpeg.StartInfo.Arguments = " -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi";
ffmpeg.Start();

任何人知道这是为什么?为什么会从DOS,然后指挥工作不能使用C#即使参数是完全一样的工作吗?我用这个方法之前,很多事情,从来没有遇到过这一点。

Any one know why this is? Why would the command work from dos and then fail to work using c# even when the arguments are exactly the same? I've used this method before for many things and never encountered this.

推荐答案

尝试完全限定的文件名中的论点 - 我注意到你指定的文件名部分的路径,所以它可能是被其他地方启动的过程中,然后没有找到论据和导致错误。

Try fully qualifying the filenames in the arguments - I notice you're specifying the path in the FileName part, so it's possible that the process is being started elsewhere, then not finding the arguments and causing an error.

如果这样的作品,然后设置WorkingDirectory在StartInfo的属性可能是有用的。

If that works, then setting the WorkingDirectory property on the StartInfo may be of use.

实际上,根据链路

在WorkingDirectory属性必须  设置,如果用户名和密码  提供。如果属性没有设置,  默认的工作目录  %SYSTEMROOT%\ SYSTEM32。

这篇关于的Process.Start()的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 09:59
查看更多