2
I need to enter the download transfer rate by FTP on progressBar
of my Form
with the code below:
private void Download(string filePath, string fileName)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + ftpServerIP + "/" + fileName);
request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
request.Method = WebRequestMethods.Ftp.DownloadFile;
using (Stream ftpStream = request.GetResponse().GetResponseStream())
using (Stream fileStream = File.Create(filePath + "\\" + fileName))
{
byte[] buffer = new byte[10240];
int read;
while ((read = ftpStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, read);
}
}
}
What needs to be done?
Gave this
'System.Threading.Tasks.Task' does not contain a definition for 'Run'
– Marlon Pereira
The project is Winforms?
– João Martins
Yes, and
NetFramework 4.0
– Marlon Pereira
Ha, ok, version 4.0 does not have this method. Edited answer.
– João Martins