Hey All..
I am downloading a file from an FTP site (Async) and need to update a progress bar. I have read MS documentation that states that this can be done is the WebClient class's GetWebRequest() is ovverriden so the 'UsePassive' property is set to 'false'. I have done this but 'DownloadProgressChanged' event argument ProgressPercentage is always == '0'.
Can someone tell me how to get this argument to start returning values?
This is the download method:
FTPClient request = new FTPClient();
request.Credentials = new NetworkCredential(user, password);
request.DownloadProgressChanged += UpdateProgress;
request.DownloadFileAsync(ftpepath,destinationpath);
This is the FTPClient (where i am overriding GetWebRequest()):
class FTPClient : WebClient
{
protected override WebRequest GetWebRequest(System.Uri address)
{
FtpWebRequest req = (FtpWebRequest) base.GetWebRequest(address);
req.UsePassive = false;
return req;
}
}
And my Callback if it helps:
void UpdateProgress(object sender, DownloadProgressChangedEventArgs e)
{
dwnProgress.Value = e.ProgressPercentage;
dwnprcnt.Text = PercentProgress.ToString() + "%";
}