문제

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