How to run and capture a command line output in C#

Asked

Viewed 405 times

0

Guys, here’s the deal. I have an app that works on a command line. This application takes parameters per command line, e.g.: program.exe [parameters] I want to make an interface where I run this application by passing the commands and capturing what the application is displaying in command line, and show it in a txtLabel. The part about passing the commands and running the app I know how to do. What I can’t get is to capture what’s coming out in a command line and display on a label.

I was thinking of making the application in cmd save the output in . txt and with the interface in c#, read this . txt and display on screen. But I believe not to be ideal.

In my case I am running youtube-dl and want to capture the output of it constantly and show on a label.

  • It would be easier for you to remove the business rule to another layer and simply build your new interface in a new Windowsforms, Web project or whatever you want.

  • Have you tried with the class Process?

  • I’ll look for her methods.

1 answer

0


  • Thank you very much. I will test, check if it works and give feedback here.

  • For nothing! Success!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.