In one of my recent assignment I was asked to provide a way to end users to upload a file directly from web application. It was quite easy, code what I am providing here is just a snippet to show how to achieve this. This is written in C# and you will need to use System.Net and System.IO to use FTP and File operation.

Of course, you should have permission to upload/download a file to ftp server with proper credential and make sure you use “ftp://” instead of “http://” for the ftp server name. Along with this you may also need to catch all the errors you will encounter during the real implementation of ftp file transfer.

here is the code to upload a file, to download you need to use “DownloadFile” method in line 18.

If you use FileUpload Control (<asp:FileUpLoad /> ) for selecting files then it will not work for larger file unless you add one entry in web config file and here is what you need to add, length value should be in the rang of 0 and 2097151 (maximum file size, you will be able to upload with this setting). Default file size supported by FileUpload control is 4 MB.