I am using Sharppcap wrapper for WinPcap and I am trying to read multiple pcap files, consecutively, in one instance of a program/ program lifetime
foreach (FILENAME in LIST) // pseudocode
{
ICaptureDevice device;
try
{
device = new SharpPcap.LibPcap.CaptureFileReaderDevice(FILENAME);
device.Open();
}
catch (Exception e){}
while ((device.GetNextPacket()) != null)
{
// Handle Packet from FILENAME
}
device.Close()
}
It traverses the first file all right, but as soon as it tries parsing the second file, it throws an AccessViolationException.
I know I can have one instance of this program for 1 pcap file, but I would really like to handle all the files in one program. Any ideas?
If you just want to read PCAP files, I'd suggest to do it by your own. The format is really simple, and you won't have any problems with some external libraries.
http://wiki.wireshark.org/Development/LibpcapFileFormat