Why in my WebClient DownloadFileAsync method downloading an Empty File?

前端 未结 4 433
情歌与酒
情歌与酒 2021-01-02 04:51

I have this C# code but the final esi.zip results in 0 length or basically empty. The URL does exist and confirms to download the file manually. I am baffled buy this.

4条回答
  •  清歌不尽
    2021-01-02 05:19

     objFeedBO = new FeedBO();
     string strfilename = System.IO.Path.GetFileName(url);
     FileStream outputStream = new FileStream(DownloadPath + "\\" + strfilename, FileMode.Create);
    
     string targetdownloadedFile = @"D:\TestZip.php";
    
     WebClient myWebClient = new WebClient();
     myWebClient.DownloadFileAsync(new Uri(url), targetdownloadedFile);
     while (myWebClient.IsBusy) { }
    

提交回复
热议问题