How to get robocopy program (or other cmd command) in WINForm?

I have a GUI program that will call cmd in this GUI program. In my case, the GUI will invoke robocopy to copy the file to the file server. And I want to show the progress in the graphical interface. So, how can I get the robocopy result and display it in my GUI.

Best regards, Yongwei Xing

+4
source share
1 answer

Use the StandardOutput stream:

 process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; // ... // read from process.StandardOutput 

Alternatively, instead of reading directly from StandardOutput you can call BeginOutputReadLine send a callback that will tell you whenever a new line is displayed.

+3
source

All Articles