private void btnUpdate_Click(object sender, EventArgs e)
{
if (ConnectionAvailable("https://www.yoursitehere.com") == true)
{
frmUpdater frmUpd = new frmUpdater(); // NOT included
frmUpd.ShowDialog(); // NOT included
}
else
MessageBox.Show("No Internet Connection available", "Error");
}
public static bool ConnectionAvailable(string strServer)
{
try
{
HttpWebRequest reqFP = (HttpWebRequest)HttpWebRequest.Create(strServer);
HttpWebResponse rspFP = (HttpWebResponse)reqFP.GetResponse();
if (HttpStatusCode.OK == rspFP.StatusCode)
{
// HTTP = 200 - Internet connection available, server online
rspFP.Close();
return true;
}
else
{
// Other status - Server or connection not available
rspFP.Close();
return false;
}
}
catch (WebException)
{
// Exception - connection not available
return false;
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.