Bon, j'espère que tu auras du temps pour savoir comment convertir du C# vers du VB.Net :
Code C# : 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public partial class MainWindow : Window { private string OutputOrErrorMessage = string.Empty; public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.ping = new Process(); this.ping.ErrorDataReceived += pingOutputOrErrorDataReceived; this.ping.OutputDataReceived += pingOutputOrErrorDataReceived; this.ping.StartInfo.FileName = "ping.exe"; this.ping.StartInfo.Arguments = "www.google.com"; this.ping.StartInfo.CreateNoWindow = true; this.ping.StartInfo.UseShellExecute = false; this.ping.StartInfo.RedirectStandardError = true; this.ping.StartInfo.RedirectStandardOutput = true; this.ping.StartInfo.StandardErrorEncoding = Encoding.ASCII; this.ping.StartInfo.StandardOutputEncoding = Encoding.ASCII; this.ping.Start(); this.ping.BeginErrorReadLine(); this.ping.BeginOutputReadLine(); this.ping.WaitForExit(); this.ping.ErrorDataReceived -= pingOutputOrErrorDataReceived; this.ping.OutputDataReceived -= pingOutputOrErrorDataReceived; MessageBox.Show(this.OutputOrErrorMessage); } private void pingOutputOrErrorDataReceived(object sender, DataReceivedEventArgs e) { this.OutputOrErrorMessage += e.Data + Environment.NewLine; } }
Partager