Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.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# 从.NET C调用Mp4Box.exe#_C#_.net_Shell_Command Line_Mp4 - Fatal编程技术网

C# 从.NET C调用Mp4Box.exe#

C# 从.NET C调用Mp4Box.exe#,c#,.net,shell,command-line,mp4,C#,.net,Shell,Command Line,Mp4,您好,我正在制作一个代码,用于使用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" 当我在命令行上手

您好,我正在制作一个代码,用于使用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#代码执行它:


返回的结果是空字符串

您不需要为此调用cmd


您应该直接调用程序,并将参数传递到
ProcessStartInfo
arguments
属性中。非常感谢您的帮助。。它成功地工作了
    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;
        }
    }