When I use DownloadDataAsync with DownloadDataCompleted, the progress bar works, it says "SUCCESS" but I couldn't find any file! Why?
When I use DownloadFileAsync with DownloadFileCompleted, it fails to download from the start. What am I doing wrong?
private void btnDownload_Click(object sender, EventArgs e)
{
string filename = @"C:\\sample.flv";
WebClient wc = new WebClient();
Uri uri = new Uri(@"http://root.alpha.lh:88/4ever.flv");
wc.DownloadProgressChanged += wc_DownloadProgressChanged;
wc.DownloadFileCompleted += wc_DownloadFileCompleted;
wc.DownloadFileAsync(uri, filename);
}
Functions like wc_*
do exists.
Are you sure the application has the permissions to write directly to c:\
? By default most applications won't.
In the case that you don't the code will fire the DownloadFileCompleted
event but it will have an exception value in the Error
property of AsyncCompletedEventArgs