問(wèn)題描述
我正在尋找一種通過(guò) C# 的 WebClient 暫停或恢復(fù)上傳過(guò)程的方法.
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();
有什么想法嗎?
推薦答案
WebClient
沒(méi)有這種功能 - 即使是稍微低級(jí)的 HttpWebRequest
也沒(méi)有不,據(jù)我所知.您將需要使用一個(gè) HTTP 庫(kù),它可以讓您在事情發(fā)生時(shí)更好地控制確切(當(dāng)然,這也將涉及更多代碼).WebClient
的重點(diǎn)是提供一個(gè)非常簡(jiǎn)單的 API 以在非常簡(jiǎn)單的情況下使用.
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.
這篇關(guān)于在 C# 中暫停/恢復(fù)上傳的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!