Easiest way to upload a collection of files to a server

uploadwebclient

Could anyone guide me as to the best way to upload a collection of files from a directory to a server from within a WPF client.
We have ftp access, and as such I have been looking at WebClient.UploadFile.

There seems to be a number of methods available through webclient though, and Im not sure which would be the most suitable.

Thanks in advance,

Best Answer

Just use WebClient.UploadFile or WebClient.UploadFileAsync to upload the files, with one call per file.

This can be as simple as:

WebClient wc = new WebClient();

foreach(var filePath in files)
    wc.UploadFile("ftp://myserver.com/path", filePath);
Related Topic