Solved

Set timeout for webClient.DownloadFile()

Posted on 2013-05-22
1
1,765 Views
Last Modified: 2013-05-25
I am trying to download a .pdf file from an URL and their webserver is very, very slow which is causing a timeout in my WebClient object.

Here is my code:

WebClient webClient = new WebClient();
webClient.DownloadFile(downloadUrl, downloadFile);

Is there a way to set an definite timeout on this object?
Or if not can anyone help me with an example on an alternate way to do this?

The URL works fine in a browser - it just takes about 3 minutes to show.

example with step by step will be appriciated.

Thanks,
Vego
0
Comment
Question by:vegoreddy
1 Comment
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39187671
use WebClient.DownloadFileAsync instead of WebClient.DownloadFile, and use your own timer, so when the timeout you decide is reached, you can call CancelAsync().
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 49
https://github.com/willowsystems/jSignature 11 73
hbo knew my windows software 4 62
asp.net web application 3 28
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question