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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top