获取 vb.net 中的下载文件大小
get the downloading file size in vb.net
我在vb.net中设计了一个下载管理器,但是我不知道如何在下载开始后,或者当我把url.
我在网上和这里搜索,我找到了 httpwebrequest
class,
但我不知道它是如何工作的以及如何将它添加到我的项目中。
使用此功能:
Public Function GetDownloadSize(ByVal URL As String) As Long
Dim r As Net.WebRequest = Net.WebRequest.Create(URL)
r.Method = Net.WebRequestMethods.Http.Head
Using rsp = r.GetResponse()
Return rsp.ContentLength
End Using
End Function
这是一个简单的使用示例:
MsgBox(Math.Round(GetDownloadSize("http://www.foo.com/file.mp3") / 1024 / 1024, 2) & " MB")
来源:
我在vb.net中设计了一个下载管理器,但是我不知道如何在下载开始后,或者当我把url.
我在网上和这里搜索,我找到了 httpwebrequest
class,
但我不知道它是如何工作的以及如何将它添加到我的项目中。
使用此功能:
Public Function GetDownloadSize(ByVal URL As String) As Long
Dim r As Net.WebRequest = Net.WebRequest.Create(URL)
r.Method = Net.WebRequestMethods.Http.Head
Using rsp = r.GetResponse()
Return rsp.ContentLength
End Using
End Function
这是一个简单的使用示例:
MsgBox(Math.Round(GetDownloadSize("http://www.foo.com/file.mp3") / 1024 / 1024, 2) & " MB")
来源: