Fast way to check if a server is accessible over the network in C#
<p>I've got a project where I'm hitting a bunch of custom Windows Performance Counters on multiple servers and aggregating them into a database.  If a server is down, I want to skip it, and just continue on with my day.</p>

<p>Currently I'm checking to see if a server is live by doing a <code>DirectoryInfo</code> on a share that I've got to look at later in the process anyways, then checking the <code>.Exists</code> property.This is my current code snippet for testing:</p>

<pre><code>DirectoryInfo di = new DirectoryInfo(machine.Share_Path);
if (!di.Exists)
{
    log.Warn("Could not access " + machine.Name + "! Maybe its down?");
    continue; // Skips to the next server in my loop where this snippet exists.
}
</code></pre>

<p>This works, but its pretty slow.  It takes about 68 seconds on average for the di.Exists bit to finish its work, and I ideally need to know within a second whether or not a server is accessible.  Pinging also isn't an option since a server can be pingable but not "live" in our environment.</p>

<p>I'm still kind of fresh to the .NET world, so I'm open to any advice people can offer.</p>

<p>Thanks in advance.</p>

<p>-Weegee</p>
