日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

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

對(duì)于VB.NET語言的應(yīng)用來說,其中有很多小技巧值得我們?nèi)フ莆眨瑏沓鋵?shí)我們的開發(fā)經(jīng)驗(yàn),以提高編程效率。比如VB.NET下載程序的實(shí)現(xiàn),就是其中一個(gè)很有用的編程技巧,能幫助我們很好的解決開發(fā)中所遇到的相關(guā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)代碼操作就為大家介紹到這里。


當(dāng)前標(biāo)題:VB.NET下載程序代碼實(shí)現(xiàn)
網(wǎng)站鏈接:http://www.5511xx.com/article/cdcogds.html