0
votes

I am following Pcap.net tutorials from its wiki on github. I tried to run code from here:

https://github.com/PcapDotNet/Pcap.Net/wiki/Pcap.Net-Tutorial-Handling-offline-dump-files

I didn't understand the following part:

if (args.Length != 1)
        {
            Console.WriteLine("usage: " + Environment.GetCommandLineArgs()[0] + " <filename>");
            return;
        }

But I run this code and Bingo, nothings happen (no output).

I tried to figure out and found that args has the value "0".

I comment return command and it start working fine till I got IndexOutOfBound exception here:

using (PacketDumpFile dumpFile = communicator.OpenDump(args[0]))

Did I missed any thing?

1
I didn't expect to talk myself all the time on "stackoverflow".Faizan Ahmed
Still nothing, I am going to select my own answer as accepted.Faizan Ahmed
And no change in my Repo.Faizan Ahmed

1 Answers

1
votes

This program require 1 argument (i.e. 'filename'in this case) that you should pass through command line.

Compile the code and run the program through command line with argument value.

For Example:

In CLI >MyProg.exe fileNmae