using System.Net.NetworkInformation;
Ping pingSender = new Ping();
PingReply reply = null;
try
{
reply = pingSender.Send('www.yisaim.com', 1000);
}
catch (Exception)
{
}
finally
{
if (reply == null || (reply != null && reply.Status != IPStatus.Success))
{
MessageBox.Show("无法连接该网站,请检查网络!", "连接网站失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (reply.Status == IPStatus.Success)
//this.Text = "连接成功";
}
使用C#判断网络是否通畅
最新推荐文章于 2020-03-31 00:14:05 发布