Click here to Skip to main content
15,435,745 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I watch multiple videos on how to do it but they only show how to make a client and server in C# sending single files over the network using TCP. but I want to know how i can change it so that i can select folders with sub folders and send it over the network

Edit: I has to work like a BackUp program. I needs to backup a specific folder on the network pc and save it on my pc

What I have tried:

I tried modifying a video on youtube but with no luck
Updated 28-Mar-17 2:34am
CHill60 28-Mar-17 8:05am    
That section "What I have tried:" is for the code you have tried.
Gerrit de Beer 28-Mar-17 8:39am    
I tried adding the code there but not everything can fit there

Here is an article on CodeProject which can get you started, you can use the FTP library which is included in the source code: A Windows FTP Application[^]
I would advise not to use the "Win7" version, as this looks a bit strange on newer versions of Windows.
Share this answer
Gerrit de Beer 28-Mar-17 8:18am    
Problem is i need to use TCP/Socket connection. I dont want to use FTP.
RickZeeland 28-Mar-17 16:26pm    
You could write something simple using WebClient, but even simpler would be to use RoboCopy, see:
Without programming:
Install an SCP or [S]FTP server on the remote machine and use an appropriate client software locally.

Open a folder selection dialog, enumerate the files in the selected folder (optionally use a file mask), and send each file like in the existing code from the examples you have found.

To process also sub folders, the enumeration must be recursive:
When the current item is a folder, create the full path from the actual one, append the sub folder name and call the function with this path.
Examples can be found by searching the web for "c# recursive directory listing".
Share this answer
Gerrit de Beer 28-Mar-17 8:37am    
Can you maybe give me an example of how the code will look?
Jochen Arndt 28-Mar-17 8:46am     CRLF
Which code? The recursive one? void ProcessFilesRecursive(string dir) {  foreach (string d in Directory.GetDirectories(dir))   ProcessFilesRecursive(d);  foreach (string f in Directory.GetFiles(dir))   SendFile(f); }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900