加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

显示下载进度条的下载文件代码

发布时间:2020-12-15 21:12:37 所属栏目:asp.Net 来源:网络整理
导读:p style="FONT-SIZE: 10pt"VB.NET br clear="all"p style="FONT-SIZE: 10pt" 0????? totalDownloadedByte = osize + totalDownloadedByte????? Application.DoEvents()????? so.Write(by,osize)????? Prog.Value = totalDownloadedByte????? osize = st.Read

<p style="FONT-SIZE: 10pt">VB.NET


<br clear="all"><p style="FONT-SIZE: 10pt">

? Public Shared Sub DownFile(ByVal URL As String,ByVal Filename As String,ByVal Prog As ProgressBar)??? Dim Myrq As HttpWebRequest = HttpWebRequest.Create(URL)??? Dim myrp As HttpWebResponse = Myrq.GetResponse??? Dim totalBytes As Long = myrp.ContentLength??? Prog.Maximum = totalBytes??? Dim st As Stream = myrp.GetResponseStream??? Dim so As Stream = New FileStream(Filename,FileMode.Create)??? Dim totalDownloadedByte As Long = 0??? Dim by(1024) As Byte??? Dim osize As Integer = st.Read(by,by.Length)??? While osize > 0????? totalDownloadedByte = osize + totalDownloadedByte????? Application.DoEvents()????? so.Write(by,osize)????? Prog.Value = totalDownloadedByte????? osize = st.Read(by,by.LongLength)??? End While??? so.Close()??? st.Close()? End Sub? 0)? {??? totalDownloadedByte = osize + totalDownloadedByte;??? Application.DoEvents();??? so.Write(by,osize);??? Prog.Value = (int)totalDownloadedByte;??? osize = st.Read(by,(int)by.Length);? }? so.Close();? st.Close();??????????? }(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!