+1 vote

Hi,

When i download a file as follows.

ftpClient.Progress += FtpClient_DownloadProgress;
ftpClient.Download(fileToDownload.Name, destination);

In the progress event handler is see that the percentage is exposed. What is the best way to know when the download or upload is 100% complete?

Obviously in the FtpClient_DownloadProgress event handler i have access to the percentage but how can i access this outside of the handler i see there is not property on the ftpClient object ?

Should i create another thread etc ?

Thanks and regards

by (720 points)

1 Answer

0 votes

If you want to track progress you need to subscribe to Progress event, they're is no other way. Remember to subscribe to the event before you start file download/upload.

When transfer finishes, Upload/Download method simply exits.

by (297k points)
edited by
So then is the Download method synchronous? So as soon as it exists the method the upload/download is completed.
The reason i'm asking is because after i've uploaded a file i move the local file but i am told it is being used by another process or is locked. So i was thinking it was the FtpUpload method that wasn't finished with the file.
Yes, it is synchronous. File is always correctly closed and its handle is disposed when it finishes.
...