Solved

Set timeout for webClient.DownloadFile()

Posted on 2013-05-22
1
1,679 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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.…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now