I have 4 laptops connected to my wifi router. I want the internet working on 2 machines only but allow all 4 to share files. What is the best way to do that?
You should be able to filter which devices you want to allow internet access to via MAC Address in the router's administration panel.
What router do you have?
The best way would be to assign static IP configuration on the two hosts.
The two hosts that connect to the internet would have all of the IP settings configured (ie IP address, subnet mask, default gateway and DNS) via DHCP while the hosts that shouldn't access the internet would be manually configured without a default gateway address.
This way the hosts would not know where to send packets that are destined for a device that is not on your local LAN.
The easiest way would be to record the IP settings that the hosts have currently been assigned before statically configuring them with the same details (minus the default gateway for the two).
You should change the last digits (ie 10.0.0.x or 192.168.1.x) to a number above the number of devices you have. So if you have 15 devices that connect to the network I would make the last digits .25 or above. This will avoid any IP address conflicts that would be caused by your router giving out the address you have statically assigned to a new workstation that requests an address using DHCP.
I hope that makes sense. Trying to explain it any further or simplify it any more would require a fairly lengthy reply.