上传期间可以从服务器获得响应吗? (C#UploadFileAsync)

时间:2019-05-17 00:53:02

标签: c# asynchronous server upload

我正在使用UploadFileAsync上传文件。

服务器开始上传后,就会发送对请求的响应。

但是,文件上传完成后,您会收到响应。 (上传完成后将调用UploadFileCompleted。)

我可以在上传过程中处理服务器的响应吗?

webClient.UploadFileCompleted += UploadFileCompletedCallback;
webClient.UploadProgressChanged += UploadProgressCallback;
webClient.UploadFileAsync("http://mydomain.test/upload.jsp", "C:\test.jpg");

private void UploadFileCompletedCallback(object sender, UploadFileCompletedEventArgs e)
{
    Console.WriteLine("UploadFileCompletedCallback");
}

private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
{
    Console.WriteLine("UploadProgressCallback : " + e.BytesSent + " / " + e.TotalBytesToSend);
}

0 个答案:

没有答案