将命令行程序输出重定向到列表框 [英] redirect command line programs output to listbox

查看:82
本文介绍了将命令行程序输出重定向到列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在寻找一种从CMD程序屏幕(FFmpeg.exe)重定向并在VISUAL STUDIO列表框中列出其进度的方法.我几乎不懂VB .net,但不懂C#.任何简单的方法都可以.看起来很不错,但是大多数优秀的方法都可以以C的形式进行演示/下载.

Been looking for a way to redirect from CMD program screen (FFmpeg.exe) and list its progress in a VISUAL STUDIO Listbox. I''m barely literate in VB .net but NOT C#. Any easy way to do it. Been looking but most excellent methods are demo''d/downloadable in some form of C.

推荐答案

问题与CMD.EXE没有关系吗?为什么这么多人认为这是唯一的控制台应用程序或控制台应用程序的某些主机?任何带有控制台的应用程序都可以在没有CMD.EXE的情况下独自在控制台中运行和显示输出,包括ffmpeg.

System.Diagnostics.Process.Start运行它.作为参数,使用可执行文件ffmpeg.exe的名称,而不是CMD.exe.对于重定向,您需要使用属性System.Diagnostics.Process.StandardOutput,以防万一,使用StandardError.

您将在此处找到完整的重定向示例:
http://msdn.microsoft.com/en-us/library/system. diagnostics.process.standardoutput.aspx [ ^ ].

另请参见:
http://msdn.microsoft.com/en-us/library/system.diagnostics. process.aspx [^ ].

—SA
The question has nothing to do with CMD.EXE? Why so many people think this is the only console application or some host for console applications? Any application with a console can run and show output in a console by itself, without CMD.EXE, including ffmpeg.

Run it with System.Diagnostics.Process.Start. As a parameter, use the name of executable file ffmpeg.exe, not CMD.exe. For redirection, you need to use the property System.Diagnostics.Process.StandardOutput, and, just in case, StandardError.

You will find complete redirection sample here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^].

See also:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^].

—SA


这篇关于将命令行程序输出重定向到列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆