After capturing packets and stop the capturing the created file is still in use

Jan 17, 2015 at 5:12 PM
i am start capturing using this function:
        public static void StartSniffing(string file, string filter)
        {
            _stopSniffing = false;
            Packet packet;
            using (PacketCommunicator _snifferCommunicator =
                NetworkAdapter.SelectedAdapter.PacketDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000))
            {
                _snifferCommunicator.SetFilter(filter);
                PacketDumpFile packetDumpFile = _snifferCommunicator.OpenDump(file);
                do
                {
                    PacketCommunicatorReceiveResult result = _snifferCommunicator.ReceivePacket(out packet);
                    if (packet != null)
                    {
                        packetDumpFile.Dump(packet);
                    }
                } while (!_stopSniffing);
            }
        }
Also i have this bool value that can be change and stop the capturing:
       public static bool StopSniffing
        {
            get { return _stopSniffing; }
            set { _stopSniffing = value; }
        }
From my main form i am open the capturing in this way:
Pcap.StartSniffing(file, filter);
Ans stop the capturing:
Pcap.StopSniffing = true;
My only problem is that after stop the capturing the created file i still in use and cannot be moved/deleted.
I try to set my _snifferCommunicator variable to Dispose but it crash.
Any idea how to do that ?
Coordinator
Jan 17, 2015 at 6:14 PM
Hi falukky,

I believe you should dispose packetDumpFile when you finish using it.

I hope this helps,

Boaz.