Click here to Skip to main content
15,304,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to write a packet on a file but it doesn't work.
C#
CaptureFileWriterDevice captureFileReader = new CaptureFileWriterDevice(devices[i], "D:\\Documents and Settings\\amin\\Mes documents\\file.pcap");

please I need help


Error 1: The overloaded method that best 'SharpPcap.LibPcap.CaptureFileWriterDevice.CaptureFileWriterDevice (SharpPcap.LibPcap.LibPcapLiveDevice, string)' has some invalid arguments
Posted
Updated 9-Nov-11 22:53pm
v3
Comments
Mehdi Gholam 10-Nov-11 4:49am
   
And what is the error you are getting?
Legor 10-Nov-11 4:49am
   
What doesnt work? Any error messages? Improve your question.
Timberbird 10-Nov-11 4:54am
   
Haven't worked with that framework, but according to description article... do you call captureFileReader.Write(e.Packet) later?
aminenjeh 10-Nov-11 4:59am
   
the prb is on the
CaptureFileWriterDevice captureFileReader = new CaptureFileWriterDevice(devices[i], "D:\\Documents and Settings\\amin\\Mes documents\\file.pcap");

Error 1: The overloaded method that best 'SharpPcap.LibPcap.CaptureFileWriterDevice.CaptureFileWriterDevice (SharpPcap.LibPcap.LibPcapLiveDevice, string)' has some invalid arguments
aminenjeh 10-Nov-11 5:00am
   
Error 2 Argument '1 ': can not convert from' SharpPcap.ICaptureDevice 'to' SharpPcap.LibPcap.LibPcapLiveDevice '
Timberbird 10-Nov-11 5:09am
   
According to this error, there may be mess with namespaces. You use SharpPcap.LibPcap.CaptureFileWriterDevice.CaptureFileWriterDevice and it rejects SharpPcap.ICaptureDevice object... is there SharpPcap.CaptureFileWriterDevice class in this framework?
aminenjeh 10-Nov-11 5:15am
   
no I don't have a SharpPcap.CaptureFileWriterDevice class in this framework
Timberbird 10-Nov-11 5:37am
   
Ok, have you tried cast?
I mean:
SharpPcap.LibPcap.LibPcapLiveDevice pDevice = devices[i] as SharpPcap.LibPcap.LibPcapLiveDevice;
if (null != pDevice)
{
CaptureFileWriterDevice captureFileReader = new CaptureFileWriterDevice(pDevice, "D:\\Documents and Settings\\amin\\Mes documents\\file.pcap");
...
}
aminenjeh 10-Nov-11 6:18am
   
thank you so much It works perfectly :)

Sorry If I disturbed you

Thank you :)
Timberbird 10-Nov-11 10:08am
   
You're welcome :)

1 solution

You should really read the FAQ before posting here: "it doesn't work" tell us near zero about your prblem.
I may just guess the above statement is throwing an exception, but you told us nothing about.
Please elaborate.
Moreover I suppose you have the source code of the framework you are using (available here[^]) hence you might delve inside it to find what is going wrong.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900