13 comments on “FTP Endeavor II – Upload and Download Files

  1. Pingback: FTP Endeavor II – Upload and Download Files

  2. Hello Can,

    Thank you so much for the samples, appreciate it a lot.

    I’m having a problem, though. When I upload a file, the server seems like keeps waiting for more data to come after the file has been uploaded. After this, the server doesn’t accept more commands and the file can’t be accessed until I close the app.

    It’s important to note that after closing the app I can access the file and it has been perfectly uploaded.

    My understanding is that when the data stream is disposed the server should assume the operation is completed, but it doesn’t look like it. Note that other commands can be issued without problem, like listing or creating a directory.

    Any ideas?

    Thank you so much again!


    • your situation seems to be similar to what Eduard is receiving below. I am going to be uploading a universal app sample in the coming days, I will try to replicate the error.


  3. Thank you very much for this examples!
    Unfortunately I get a “System.ObjectDisposedException” on uploading a mp4 from WP 8.1 IsoStorage.
    Finally I have a 0 Byte file on the server. Do you have an idea for the reason?


    • hey, no problems… I really have no idea what is going on… which type of ftp server were you using for this scenario? I will uploading a universal app sample in the coming days… will try to replicate the issue during testing…


      • I used my web hoster ftp. But also the xampp ftp. I think the problem is the method you are using to read and write the file. This is a very hard topic for me so can’t give you more information. And you should use a larger file for testing. > 5MB.


  4. Porting to Windows 10 for a windows 10 app (app requires a specific windows 10’s feature).

    I’m getting a ‘System.Runtime.InteropServices.COMException’ in mscorlib.ni.dll exception

    “WinRT information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.”

    in FtpStreamChannel’s method public async Task ConnectAsync(HostName host, string service)

    after calling await ftpClient.GetListingAsync() in my app.

    So far GetListingAsync() , FileExistsAsync(), OpenWriteAsync() all fires the System.Runtime.InteropServices.COMException

    This seems to happen after any method that sets mode to EPSV

    REPLY :229 Entering Extended Passive Mode (|||5093|)

    thread exits messages, then error. I know EPSV is established based on the reply.

    I know MS changed the way they did sockets for 8.1/10, mainly that they didn’t include a method to close the socket when your done with it, but instead rely on garbage collection. There seems to be issues with the WinRT kernel when knowing when that will be done. StackExchange mentions deleting the pointer in C++ but this of course is C#.

    tested connection with WinSCP, seems to work fine. non loopback, external ftp. Turned off firewall, same issue.

    Making directory, connecting, all seem to be fine.

    Any suggestions?


    • found my own issue here.. seems to be if the ftp server doesnt provide root folder access, need to specify the path… or things fall apart.

      still couldnt get the file to transfer… some reason hangs on a handle to the file and 0B until forced closed.


  5. Thank you very much for your example! It helped me a lot to get started. Uploading a single file is working very good, but when I make a loop with multiple Files, it is not working. It looks like the Stream for writing on the FTP Server is not correctly flushed or closed. An ugly fix right now is the Disconnect after the first File was uploaded and then reconnect in the loop. Is there something missing? Like a command for the FTP that the STOR is complete?


  6. Hey hi

    How can i upload a large file let say ->> 500 or 700 mb over FTP, at a great speed.
    I am targeting a speed of 20mb/s, i have successfully transferred the FILE data to FTP at a speed of 1mb/s through my mobile device (UWP application).

    Can you help me in any case with the uploading of FILE at a much faster speed.
    -> Should i be altering the Byte Array size or anything.

    Thanks and Regards in advance


  7. Hi

    I am targeting a FTP upload of a large file say 700mb at a great speed say 30-40mb/s from my mobile device i.e. UWP application.

    I have successfully transferred the File to FTP but at a lower speed viz. 1mb/s

    Can you help me and comment on how can i do a faster FTP upload from Windows 10 device.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s