zoukankan      html  css  js  c++  java
  • c#调用EXE文件方法

     static void ExcuteProcess(string exe, string arg, DataReceivedEventHandler output)
        {
            using (var p = new Process())
            {
                p.StartInfo.FileName = exe;
                p.StartInfo.Arguments = arg;

                p.StartInfo.UseShellExecute = false;    //输出信息重定向
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.RedirectStandardError = true;    
                p.StartInfo.RedirectStandardOutput = true;

                p.OutputDataReceived += output;
                p.ErrorDataReceived += output;

                p.Start();                    //
    启动线程
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
                p.WaitForExit();            //
    等待进程结束
            }
        }

     

    调用

     ExcuteProcess("ffmpeg.exe", "-y -i 1.flv 1.mp3", (s, e) => Console.WriteLine(e.Data));

     

  • 相关阅读:
    Python staticmethod() 函数
    Python open() 函数
    Python input() 函数
    Python divmod() 函数
    Python abs() 函数
    instanceof和类型转换
    多态
    方法重写
    this
    Super详解
  • 原文地址:https://www.cnblogs.com/studyplay/p/1881500.html
Copyright © 2011-2022 走看看