Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How do I check that I have an open network connection and can contact a specific ip address in c#? I have seen example in VB.Net but they all use the 'My' structure. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
321 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you just want to check if the network is up then use:

bool networkUp
    = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

To check a specific interface's status (or other info) use:

NetworkInterface[] networkCards
    = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

To check the status of a remote computer then you'll have to connect to that computer (see other answers)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...