为什么我用webclient加For循环下载时,到第二个就不下载了?
vb.net吧
全部回复
仅看楼主
level 13
wahaha216 楼主
写了个更新程序用的,然后读取远程文本,再分割下载列表到listbox里
之后有个按钮是更新
这是部分代码
Dim dFile As New WebClient
Dim DFileName As String
Dim temp1() As String
For i = 0 To ListBox2.Items.Count - 1
temp1 = ListBox2.Items.Item(i).Split("/")
DFileName = temp1(temp1.Count - 1)
update_(DFileName, New Uri(Url & ListBox2.Items.Item(i)))
Do Until Download_Find
Application.DoEvents()
Loop
Next
Private Sub update_(DFileName As String, DUri As Uri)
Myrq = CType(WebRequest.Create(DUri), HttpWebRequest)
Myrq.Method = "GET"
myrp = CType(Myrq.GetResponse(), HttpWebResponse)
dFile = New WebClient
AddHandler dFile.DownloadProgressChanged, AddressOf ShowDownProgress
AddHandler dFile.DownloadFileCompleted, AddressOf DownloadFileCompleted
dFile.DownloadFileAsync(DUri, Application.StartupPath & "\" & DFileName)
End Sub
第一个从获取大小到下载完成一切正常
第二个能获取到大小,但是一直没有已下载的字节数据,到目录里去右键属性也是0字节
2016年03月13日 04点03分 1
level 13
写法不标准。因为Async方法没有Await。
---贴吧极速版 For UWP
2016年03月13日 04点03分 2
那该怎么写呢?
2016年03月13日 05点03分
回复 哇哈哈216 : 你自己查查这两个关键字怎么用 ---贴吧极速版 For UWP
2016年03月13日 08点03分
@Nukepayload2 我这个是在.NET 3.5下写的。使用await之后提示表达式不产生值(没有DownloadFileTaskAsync)
2016年03月13日 09点03分
回复 哇哈哈216 : 至少要4.5 ---贴吧极速版 For UWP
2016年03月13日 09点03分
level 9
这样看起来好别扭,还是截个清楚地图比较好[吐舌]
2016年03月13日 06点03分 3
level 1
你好 请问下你是怎么解决的啊 我也遇到这个问题了 [泪]
2016年07月11日 12点07分 6
level 9
原来你也是用webclient下载的[滑稽]
2017年01月27日 04点01分 7
level 9
我是不是挖了个坟[阴险]
2017年01月27日 04点01分 8
1