Post by bobowk on Feb 21, 2017 20:02:43 GMT 10
How can I detect in c# if there is a network connection. Thanks!
|
|
Post by Imformas on Feb 22, 2017 1:09:30 GMT 10
if(System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable ()) { // There is a network connect } else { // There isn't an active network connection } It will return True if there is a network connection and False if there isn't
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|
Post by bobowk on Feb 23, 2017 19:56:47 GMT 10
|
|
Post by Imformas on Feb 23, 2017 20:08:01 GMT 10
Bruh, that's how you check for an internet connect if(System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up) { } I checked by disabling my internet connection on my router, and it returned False, when it was disabled, and True when it was active. Test it yourself man. it'll work!
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|
Post by altair on Feb 24, 2017 1:49:51 GMT 10
You could also just use something like WebClient and try downloading something from a website (like Google) and if a exception is thrown.... Then its offline (presumably ) I am not a fan of this.. But it works ¯\_(ツ)_/¯
|
|
Post by bobowk on Feb 24, 2017 21:35:52 GMT 10
Sorry for not being clear. There is a setting in cefsharp that detects if there is no internet. I've tried, but failed.
|
|