Skip to content

Instantly share code, notes, and snippets.

@AungWinnHtut
Created August 3, 2016 06:45
Show Gist options
  • Save AungWinnHtut/58f2f804b8fe1394733ff39afe3fd565 to your computer and use it in GitHub Desktop.
Save AungWinnHtut/58f2f804b8fe1394733ff39afe3fd565 to your computer and use it in GitHub Desktop.
public bool IsConnectionAvailable()
{
System.Uri objUrl = new System.Uri("http://google.com");
System.Net.WebRequest objWebReq = default(System.Net.WebRequest);
objWebReq = System.Net.WebRequest.Create(objUrl);
System.Net.WebResponse objresp = default(System.Net.WebResponse);
try {
objresp = objWebReq.GetResponse;
objresp.Close();
objresp = null;
return true;
} catch (Exception ex) {
objresp = null;
objWebReq = null;
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment