Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!

I am running into an issue with using the WebClient.DownloadFile command. It works with small files, but when I try to use it to download ~300MB file, it doesn't download the entire file.

Here is what I have so far:
C#
WebClient webClient = new WebClient();
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
                webClient.DownloadFileAsync(new Uri(@"https://mysite/waveform_db.sdf"), @"c:\db.sdf");

Is there a way I can make sure it downloads the entire file?
Posted
Updated 16-Nov-12 10:49am
v2

1 solution

This API is very much simplified. For bigger files, the ability to continue downloading after connection was lost or application terminated and other advanced cases, use System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].

You can download the source code of my ready-to-use application HTTPDownloader with that implements that "continue downloading" feature and see how it works:
how to download a file from internet[^].

See also my past answers:
FTP: Download Files[^],
how to download a file from the server in Asp.net 2.0[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 17-Nov-12 8:59am    
Good points :-D
Sergey Alexandrovich Kryukov 17-Nov-12 21:17pm    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900