C# 为什么我';我在processinfo上获得System.ComponentModel.Win32Exception以及如何修复它?

C# 为什么我';我在processinfo上获得System.ComponentModel.Win32Exception以及如何修复它?,c#,.net,winforms,C#,.net,Winforms,在我的form1 top中: string InputFile = @"e:\lightningsmov\MVI_7909.MOV"; string OutputFile = @"e:\lightningsmov\MVI_7909.mp4"; string cmd; string exepath = @"E:\myffmpegstatic\ffmpeg-20151217-git-9d1fb9e-win64-static\bin\ffmpeg.exe"; string placeholder;

在我的form1 top中:

string InputFile = @"e:\lightningsmov\MVI_7909.MOV";
string OutputFile = @"e:\lightningsmov\MVI_7909.mp4";
string cmd;
string exepath = @"E:\myffmpegstatic\ffmpeg-20151217-git-9d1fb9e-win64-static\bin\ffmpeg.exe";
string placeholder;
在构造函数中:

label2.Text = InputFile;
cmd = " -i \"" + InputFile + "\" \"" + OutputFile + "\"";
initProgressBar();
initProgressBar:

private void initProgressBar()
        {
            progressBar1.Style = ProgressBarStyle.Continuous;
            // for every line written to stdOut, raise a progress event
            int result = SpawnProcessSynchronous(InputFile, cmd, out placeholder, false,
                (sender, eventArgs) =>
                {
                    if (eventArgs.Data.StartsWith("TotalSteps="))
                    {
                        progressBar1.Minimum = 0;
                        progressBar1.Maximum = Convert.ToInt32(eventArgs.Data.Replace("TotalSteps=", ""));
                        progressBar1.Value = 0;
                    }
                    else
                    {
                        progressBar1.Increment(1);
                    }
                });
        }
以及以下各项:

public static int SpawnProcessSynchronous(string fileName, string args, out string stdOut, bool isVisible, DataReceivedEventHandler OutputDataReceivedDelegate)
        {
            int returnValue = 0;
            var processInfo = new ProcessStartInfo();
            stdOut = "";
            processInfo.FileName = fileName;
            processInfo.WorkingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ?? "";
            //log.Debug("Set working directory to: {0}", processInfo.WorkingDirectory);

            processInfo.WindowStyle = isVisible ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;
            processInfo.UseShellExecute = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.CreateNoWindow = true;

            processInfo.Arguments = args;
            using (Process process = Process.Start(processInfo))
            {
                if (OutputDataReceivedDelegate != null)
                {
                    process.OutputDataReceived += OutputDataReceivedDelegate;
                    process.BeginOutputReadLine();
                }
                else
                {
                    stdOut = process.StandardOutput.ReadToEnd();
                }
                // do not reverse order of synchronous read to end and WaitForExit or deadlock
                // Wait for the process to end.  
                process.WaitForExit();
                returnValue = process.ExitCode;
            }
            return returnValue;
        }
以下行的SpawnProcessSynchronous中存在异常:

using (Process process = Process.Start(processInfo))
指定的可执行文件不是此操作系统平台的有效应用程序

堆栈跟踪:

at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at ConvertVideo.Form1.SpawnProcessSynchronous(String fileName, String args, String& stdOut, Boolean isVisible, DataReceivedEventHandler OutputDataReceivedDelegate) in d:\C-Sharp\ConvertVideo\ConvertVideo\ConvertVideo\Form1.cs:line 88
第88行是:

using (Process process = Process.Start(processInfo))

我认为你弄乱了流程启动信息参数

int result = SpawnProcessSynchronous(InputFile, cmd, ...
应该是

int result = SpawnProcessSynchronous(exepath, cmd,

您的ffmpeg是cygwin版本吗?或者它是64位版本,而您使用的是32位版本的windows?