我有这个问题:这是我的代码:
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();
}
并且它已经开始了,但我希望在ProgressBar
中使用回调来显示上传的百分比和下载的相对字节数...
我该怎么做?