Bonjour,
Je voudrais rediriger la sortie standard actuelle (quand je fais un appel à Console.WriteLine() ) vers une textbox.
J'ai tenté ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 void Main() { Process currentProc = Process.GetCurrentProcess(); currentProc.StartInfo.RedirectStandardOutput = true; currentProc.StartInfo.UseShellExecute = false; currentProc.OutputDataReceived += proc_DataReceived; currentProc.BeginOutputReadLine(); Console.WriteLine("test de redirection console vers textbox ?"); } void proc_DataReceived(object sender, DataReceivedEventArgs e) { textBoxMessageViewer.AppendText(e.Data); }
Mais j'ai comme erreur :
MSDN me dit d'assigner RedirectStandardOutput à true et UseShellExecute à false, c'est ce que j'ai fait.BeginOutputReadLine(); : StandardOut has not been redirected or the process hasn't started yet.
Une idée ?
Merci pour votre aide.
Partager