0

こんにちは私はmp4box.exeを使用してmp4ビデオの編集を行うためのコードを作成しています

このコマンドラインを実行したい:

 "D:\Work\Me\CloudContentUpload\trunk\ContentUploading Current\bin\Debug\Mp4Box\Mp4Box.exe" -isma -inter 500 "C:\Users\Abdullah\Desktop\videoo\amr khaled - Asmaa_elmogeb\Asmaa_elmogeb(1).mp4"

このコマンドは、コマンドラインで手動で実行すると正常に実行されました

しかし、私は次のC#コードでそれを実行しようとします:

    public string ExecuteCommandSync(object command)
    {
        try
        {
            // create the ProcessStartInfo using "cmd" as the program to be run,
            // and "/c " as the parameters.
            // Incidentally, /c tells cmd that we want it to execute the command that follows,
            // and then exit.
            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);

            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.
            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute = false;
            // Do not create the black window.
            procStartInfo.CreateNoWindow = true;
            // Now we create a process, assign its ProcessStartInfo and start it
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;

            proc.Start();
            // Get the output into a string
            string result = proc.StandardOutput.ReadToEnd();
            // Display the command output.
            return result;
        }
        catch (Exception objException)
        {
            return objException.Message;
        }
    }

返される結果は空の文字列です!!

4

1 に答える 1

1

このためにcmdを呼び出す必要はありません。

プログラムを直接呼び出して、のArgumentsプロパティに引数を渡す必要がありますProcessStartInfo

于 2012-04-25T13:02:18.630 に答える