1

I've got this question: here is my code:

public async Task<string> UploadFile(byte[] fileBytes, string destName)
{      
  FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://xxx.xxx.xxx.xxx" + destName);
  request.Method = WebRequestMethods.Ftp.UploadFile;
  request.Credentials = new NetworkCredential("username", "password");
  request.UseBinary = true;
  request.UsePassive = true;
  request.ContentLength = fileBytes.Length;
  using (Stream s = request.GetRequestStream())
  {
    s.Write(fileBytes, 0, fileBytes.Length);
  }          
  WebResponse ftpResp = await (Task<WebResponse>)request.GetResponseAsync();
  return ftpResp.ToString();
}

and it woks, but I wish had a callback to use into a ProgressBar to show the percentage of the upload and the relative bytes downloaded...

How can I do this?

Jack
  • 102
  • 1
  • 14
ghiboz
  • 7,863
  • 21
  • 85
  • 131

0 Answers0