1

I'm trying to make a P2P application with WCF and so far it seems simple enough and I've managed to send simple string messages but that's about it. I'd like to send files in the same manner, but I can't find any useful tutorials on it. All I find is different ways to build chat applications. Are there any useful resources on how to send files in a P2P mesh?

Currently I'm going off of a slightly modified version of this. I've found a similar example on how to send and retrieve files from a server with WCF, but I don't know if it's in any way compatible with the structure I already have since it uses a different binding.

Valyrion
  • 2,342
  • 9
  • 29
  • 60

1 Answers1

1

The file transfer example that you link to uses streaming

There are only 4 bindings that support streaming, unfortunatly the peer binding that you are using is not among them.

What you can do is to create a WCF contract that has 2 properties, file_name and file_contents. The file name is a string and the file contents is a byte array. Then you can convert the file to a byte array and send it over the same way as you send over a string.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
  • This works great, thanks! One question though, is there a maximum file size limit I have to account for or do large files not make that much of a difference? – Valyrion Dec 31 '11 at 15:40
  • 1
    The default message size is 64KB but it can be increased to 2GB, see http://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota – Shiraz Bhaiji Dec 31 '11 at 15:51