[C#] Récupérer la sortie d'un programme DOS
Bonjour,
j'ai créer un process pour lister les répertoires à l'aide de la fonction DIR.
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.Arguments = "dir";
proc.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
proc.StartInfo.CreateNoWindow = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
textBox1.Text = output; |
Le problème c'est qu'il faut que j'attende que le programme soit terminé pour que ma textbox1 affiche la sortie.
Ma question est simple, peut-on récupérer en temps réel la sortie.
Merci. ;)