Reputation: 592
I'm having trouble looking for a way to send whole folders over TCP. My initial idea was that the sender sends a string that contains the path of a given file like C://MyFolder/MySubFolder/MyFile then the receiver creates the folders and subfolders. The sender then goes ahead with the sending of the files containing their directory.
I think it goes without saying that this is not the best method in doing this. Is there a better approach?
EDIT:
Sorry if I was a little vague. I have a file transfer app that sends sends/receives files obviously and I want to add a way to send whole folders.
Upvotes: 1
Views: 2177
Reputation: 395
If you consider zipping/compressing: You could have a look at GZipStream class for that.
http://www.geekpedia.com/tutorial190_Zipping-files-using-GZipStream.html
Upvotes: 0
Reputation: 25742
You need some sort of a file transfer protocol for that (i.e. FTP). Use an easy to setup c# FTP server library (i.e. this one: http://sourceforge.net/projects/csftpserver/) on the sending side and use FtpWebRequest
on the client side to get the whole folder structure.
Upvotes: 2
Reputation: 180954
Have you looked at existing protocols for this purpose? It seems you want to clone FTP, maybe with a streaming mechanism like tar in between.
Upvotes: 1
Reputation: 30857
Use famous archiving methods (zip, rar...) and transfer data. The extract the at the peer side. This way you save:
Upvotes: 1