Search code examples
c#network-programmingnetbios

How to check if a computer is responding from C#


What is the easiest way to check if a computer is alive and responding (say in ping/NetBios)? I'd like a deterministic method that I can time-limit.

One solution is simple access the share (File.GetDirectories(@"\compname")) in a separate thread, and kill the thread if it takes too long.


Solution

  • Easy! Use System.Net.NetworkInformation namespace's ping facility!

    http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx