/// <summary>
/// 聯網檢測20200529
/// </summary>
public void 網絡() {
Ping pingSender = new Ping();
PingReply reply = null;
try
{
reply = pingSender.Send("www.baidu.com", 1000);
}
catch (Exception)
{
}
finally
{
if (reply == null || (reply != null && reply.Status != IPStatus.Success))
{
btn_Update.Enabled = false;
btn_Add.Enabled = false;
labelnetwork.Text = "無法連接該網站,請檢查網絡! 連接網站失敗";
MessageBox.Show("無法連接該網站,請檢查網絡!", "連接網站失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (reply.Status == IPStatus.Success) {
labelnetwork.Text = "網絡連接成功......";
btn_Update.Enabled = true;
btn_Add.Enabled = true;
}
//this.Text = "連接成功";
}
}