How can a C# app easily communicate and transfer files on a network?

Robin Rodricks picture Robin Rodricks · Aug 9, 2009 · Viewed 20.4k times · Source

How can a C# app easily communicate with an instance of itself present on another computer, which is on the same network, and transfer files and data?

Assuming the computers on the network have fixed local IP addresses, and they each know each others IPs. Would there also be a way to communicate if the IPs are unknown? based on some discovery protocol?

I heard the "Bonjour" service from Apple was a good protocol. Can we communicate via it from our Windows apps? Or do you have to use "sockets". I'm primarily looking for libraries or sample code that can fulfill my need easily, I don't want to develop my own TCP-based protocol or anything hardcore!

Answer

ecleel picture ecleel · Aug 9, 2009

You can use System.Net.Sockets class to communicate and it have a method for sending file Socket.SendFile.

Update:
this is a good example for file sharing and sending file from C# help