1

I'm looking at the SharpPcap tutorial and am trying to understand how to access the device details, which from this post: In SharpPCap How do I find the IP Address of the Device? indicates that I must cast the ICaptureDevice object into a specific type such as WinPcapDevice.

They show how to iterate over the device list, but not how to do the type cast:

// Retrieve all capture devices
var devices = CaptureDeviceList.Instance;

// differentiate based upon types
foreach (ICaptureDevice dev in devices)
{
  if (dev is AirPcapDevice)
  {
    // process as an AirPcapDevice
  }
  else if(dev is WinPcapDevice)
  {
    // process as an WinPcapDevice
  }
  else if(dev is LibPcapLiveDevice)
  {
    // process as an LibPcapLiveDevice
  }
}
Community
  • 1
  • 1
Alan
  • 3,715
  • 3
  • 39
  • 57

0 Answers0