private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = OnLine() ? "已连接" : "未连接";
}
public bool OnLine()
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
///注:
/// 选一个好的host ,这里只是举个例子
System.Net.NetworkInformation.PingReply pr = ping.Send("wjshan0808.3vhost.net", 12000);
return pr.Status == System.Net.NetworkInformation.IPStatus.Success;
}