I'm writing an C# application, where the user can select an entire folder and click on a button to upload the folder he choose.
It is possible to upload an entire Folder to a Server(with all its files and sub folders) ?
I found in the web examples, to how to upload a single file but not an entire folder, If some one have a link or an a piece code I'll appreciate.

Thanks in advanced

Recommended Answers

All 3 Replies

Sure it's possible! The trick is to scan the directory using System.IO.Directory.GetFiles() and System.IO.Directory.GetDirectories() [make sure to do it recursively]

Then you can upload each file one at a time. If you need help with that here's a link to my site on uploading files via FTP.

By the way, you can use FTP functions to create the directory structure in the server if you needed to.

Hope that helps!

Thanks for the response, I don't have ftp server and I don't want to create one.
I was wandering if there is a way to upload the entire directory not with ftp.
I found examples how to upload multiple files using the FileUpload control, but the problem is that the user has to choose every file at the time.
I someone know how to add files to the FileUpload control in a silent way(without prom it to the user), this should help.
Thanks in advanced

can show me how to upload file to server?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.