- Code: Select all
private void button1_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
try
{
byte[] result = webClient.DownloadData(URLtext.Text);
label1.Text = "Online";
}
catch
{
label1.Text = "Offline";
}
}
My other attempt was using a thing like:
- Code: Select all
var ping = new System.Net.NetworkInformation.Ping();
var result = ping.Send("www.google.com");
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
return;
But when I enter an IP:Port it will always show offline!.. How do I make this work?