VB.NET, C#, PowerShellを使用しているエンジニアのためのサイト。
基本的な使用方法から開発で役立つTipsまで幅広く取り扱っています。
<< 前のTips 次のTips >>
Pingを実行するにはPingクラスのSendメソッドを使用します。Sendメソッドは実行結果をPingReplyとして返します。このPingReplyのStatusプロパティがSystem.Net.NetworkInformation.IPStatus.SuccessであればPingが成功したことを意味します。
System.Net.NetworkInformation.Ping pg = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply pr; pr = pg.Send("www.google.com"); if (pr.Status == System.Net.NetworkInformation.IPStatus.Success) Console.WriteLine("Ping成功"); else Console.WriteLine("応答がありませんでした");
System.Net.NetworkInformation.Ping pg = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply pr; //タイムアウト値1秒を指定してPing実行 pr = pg.Send("www.google.com", 1000); if (pr.Status == System.Net.NetworkInformation.IPStatus.Success) Console.WriteLine("Ping成功"); else Console.WriteLine("応答がありませんでした");
<< 前のTips 次のTips >>