Click here to Skip to main content
11,804,574 members (93,542 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Forms VS2012
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:
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 16-Nov-12 9:31am
Edited 16-Nov-12 10:49am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^].

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 2.0[^].

Espen Harlinn at 17-Nov-12 8:59am
Good points :-D
Sergey Alexandrovich Kryukov at 17-Nov-12 21:17pm
Thank you, Espen.

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

  Print Answers RSS
0 OriginalGriff 3,140
1 Maciej Los 1,910
2 KrunalRohit 1,907
3 CPallini 1,845
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100