日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
VB.NET下載程序代碼實(shí)現(xiàn)

對(duì)于VB.NET語(yǔ)言的應(yīng)用來(lái)說(shuō),其中有很多小技巧值得我們?nèi)フ莆?,?lái)充實(shí)我們的開(kāi)發(fā)經(jīng)驗(yàn),以提高編程效率。比如VB.NET下載程序的實(shí)現(xiàn),就是其中一個(gè)很有用的編程技巧,能幫助我們很好的解決開(kāi)發(fā)中所遇到的相關(guān)問(wèn)題。

VB.NET下載程序代碼示例:

 
 
 
  1. Public Shared fpath As String  
  2. Dim fsize As Long  
  3. Private Sub Button1_Click(ByVal sender As System.Object, 
    ByVal e As System.EventArgs) Handles Button1.Click  
  4. Try  
  5. If Me.TextBox1.Text = "http://" Then  
  6. MessageBox.Show("請(qǐng)輸入正確的URL!")  
  7. Return  
  8. End If  
  9. Dim urld As String  
  10. Dim i As Integer  
  11. Dim dfile As New WebClient  
  12. Me.SaveFileDialog1.ShowDialog()  
  13. fpath = SaveFileDialog1.FileName  
  14. Label3.Text = "文件保存在:" & fpath  
  15. urld = Me.TextBox1.Text  
  16. Me.Timer1.Enabled = True 
  17. dfile.DownloadFile(urld, fpath.Substring
    (Me.TextBox1.Text.ToString.LastIndexOf("."), 4))  
  18. Me.Timer1.Enabled = False 
  19. Catch ex As Exception  
  20. MessageBox.Show(ex.Message)  
  21. Return  
  22. Application.Exit()  
  23. End Try  
  24. End Sub 
 
 
 
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, 
    ByVal e As System.EventArgs) Handles Timer1.Tick  
  2. Dim th2 As New th1  
  3. Dim tt As New System.Threading.Thread(AddressOf th2.timeth) 
  4. '實(shí)例化線程類   
  5. tt.Start() '啟動(dòng)線程   
  6. Label2.Text = th2.downk '顯示下載文件的大小   
  7. '進(jìn)行計(jì)算下載速度   
  8. Static k As Integer  
  9. Dim p, downspeed  
  10. p = k 
  11. k = p + 1  
  12. p = k 
  13. Dim form As New DownLoad  
  14. Dim fileinfo As New System.IO.FileInfo(form.fpath)  
  15. downspeed = fileinfo.Length()  
  16. downspeeddownspeed = downspeed / p  
  17. Label4.Text = "當(dāng)前下載速度是" & downspeed & "k/m"  
  18. End Sub  
  19. End Class  
  20. Public Class th1  
  21. Public Shared downk As String  
  22. Dim form As New DownLoad  
  23. Dim fileinfo As New System.IO.FileInfo(form.fpath)  
  24. Dim fsize As Long  
  25. Public Sub timeth()  
  26. If fileinfo.Exists = True Then  
  27. fsize = fileinfo.Length()  
  28. downk = "以下載文件" & fsize & "k"  
  29. End If  
  30. End Sub  
  31. End Class 

VB.NET下載程序的相關(guān)代碼操作就為大家介紹到這里。


本文名稱:VB.NET下載程序代碼實(shí)現(xiàn)
本文路徑:http://www.dlmjj.cn/article/cdcogds.html