在C#中暂停/恢复上传

问题描述:

我正在寻找一种方法来暂停或继续通过C#的Web客户端的上传过程

I'm looking for a way to pause or resume an upload process via C#'s WebClient.

伪代码:

WebClient Client = new WebClient();
Client.UploadFileAsync(new Uri("http://mysite.com/receiver.php"), "POST", "C:\MyFile.jpg");

也许是这样..

Client.Pause();

任何想法?

Web客户端没有按'吨有这种功能 - 即使是略较低级别的的HttpWebRequest 不,据我所知。你需要使用一个HTTP库,为您提供更多的控制权的究竟的事情时有发生(这无疑会涉及到更多的代码为好,当然)。 Web客户端的一点是要提供一个非常简单的API的使用非常简单的情况。

WebClient doesn't have this kind of functionality - even the slightly-lower-level HttpWebRequest doesn't, as far as I'm aware. You'll need to use an HTTP library which gives you more control over exactly when things happen (which will no doubt involve more code as well, of course). The point of WebClient is to provide a very simple API to use in very simple situations.