Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Forms VisualStudio2012 , +
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 10:31am
Edited 16-Nov-12 11:49am
v2

1 solution

Rate this: bad
good
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:
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
  Permalink  
Comments
Espen Harlinn at 17-Nov-12 8:59am
   
Good points :-D
Sergey Alexandrovich Kryukov at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
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