开发者

WebClient: Abort Download?

I'm using WebClient to mine a bunch of data. To conserve bandwidth (for both the client and web server), and speed my program up, I'd like to abort certain downloads early if it becomes evident that the file I'm开发者_运维百科 downloading doesn't contain the information I'm looking for.

I'd like to base this decision based on the headers (mime type and file size), and possibly some of the content.

I'm presently using webClient.DownloadData, but I'd obviously have to switch this to an asynchronous method call. However, the async version doesn't pass the information I need either (headers and data). Is there perhaps another freely available class that meets these requirements?

Something that fires an event as soon as the headers have completed downloading would be nice, and periodically with progress updates.


If you want to decide whether or not to download something based on the headers, you can also send a HTTP HEAD request, which tells the server to only reply its headers.


Use the WebRequest class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜