I have a lan cable and I have connected both of them directly but still am unable to connect both of them and transfer files.
To couple directly you need a "crossover cable" not a standard patch cable.
check both ends of your lan cable is it the same at both ends or as per the above images in the link?
If you have correct cable then yu need to enable file sharing and share the files on both machines.
You may also need to configure your firewalls on both machines to allow access.
click here section 2