WebClient 下载不完整的文件 [英] WebClient downloads an incomplete file

查看:37
本文介绍了WebClient 下载不完整的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一周前写的这个方法运行良好,但现在它下载了一个不完整的文件.原始文件将近 10mb,但正在下载的文件是 2k.我的代码基本上是这样的

This method that I wrote was working fine a week ago but now it downloads an incomplete file. The original file is nearly 10mb but the file that is being downloaded is 2k. My code is basically this

Dim URL as string = "http://www.cqc.org.uk/sites/default/files/cqc_locations_export.csv"
Dim path as string = "C:\temp"        
Dim webClient As New WebClient
webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)")
webClient.DownloadFile(URL, path)

知道这里出了什么问题吗?

Any idea what is going wrong here ?

干杯

推荐答案

实际上,您可能想尝试三件事:

On ground you may want to try three things :

  1. 使用管理员权限运行您的应用程序,因为 C 驱动器受保护Windows 7 及更高版本.
  2. 暂时停止您的防病毒程序,然后再次尝试下载.
  3. 仅在下载完成时处理 webClient(On DownloadFileCompleted 事件)

这篇关于WebClient 下载不完整的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆