Jump to content
zachary1337

progressbar , download [.NET]???

Recommended Posts

In mod normal, cand descarci un fisier de pe o pagina net spre exemplu, serverul iti trimite marimea fisierului.

O iei din headere. De acolo doar calculezi procentul descarcat.

Formula ar fi:

(biti descarcati * total biti)/ 100;

si pui progres bar-ul la valoarea respectiva(eventual rotunjesti sa fie valoare intreaga).

Link to comment
Share on other sites

Form1

1 buton numit : Button1

2 timer numite : Timer1 (interval 500), Timer2 (interval 100)

1 progressbar numit : ProgressBar1

In loc de "C:\Users\Admin\Desktop\eu.exe" pui locatia din pc-ul tau unde vrei sa-ti descarce .

Dublu clik pe Form1 ,sterge codul si adauga :


Imports System.Net
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(10)
If ProgressBar1.Value = 50 Then
Timer2.Start()
End If
If ProgressBar1.Value = 100 Then
Me.Close()
End If
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

Dim client As New System.Net.WebClient
Dim adresa_fisier As String = "http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe"
client.DownloadFile(adresa_fisier, "C:\Users\Admin\Desktop\eu.exe")

End Sub
End Class

Edited by daatdraqq
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...