94 lines
4.5 KiB
VB.net
94 lines
4.5 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Net
|
|
Imports System.Reflection.Emit
|
|
|
|
Public Class Form25
|
|
Dim téléchargement = 0
|
|
Dim fichiersetrouvelas As String = ""
|
|
|
|
Private Sub Form25_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Label1.Hide()
|
|
|
|
If dldos = "" Then
|
|
If FolderBrowserDialog1.ShowDialog = 1 Then
|
|
My.Computer.Network.DownloadFile(ipsite & "extrème downloaders/utilisateur/" & nomutilisateur & "/liste/" & Form2.ComboBox4.SelectedItem & "/" & Form2.ListBox1.SelectedItem & "/download.txt", dostemps & "\download.txt")
|
|
Dim lines1() As String = File.ReadAllLines(dostemps & "\download.txt")
|
|
Dim dl = lines1(0)
|
|
File.Delete(dostemps & "\download.txt")
|
|
fichiersetrouvelas = Form2.ListBox1.SelectedItem
|
|
téléchargement = 1
|
|
ProgressBar1.Show()
|
|
téléchargerfr = New WebClient
|
|
téléchargerfr.DownloadFileTaskAsync(New Uri(dl), (dostemps & "\" & Form2.ListBox1.SelectedItem & ".zip"))
|
|
Else
|
|
Close()
|
|
End If
|
|
Else
|
|
fichiersetrouvelas = Form2.ListBox1.SelectedItem
|
|
FolderBrowserDialog1.SelectedPath = dldos
|
|
My.Computer.Network.DownloadFile(ipsite & "extrème downloaders/utilisateur/" & nomutilisateur & "/liste/" & Form2.ComboBox4.SelectedItem & "/" & Form2.ListBox1.SelectedItem & "/download.txt", dostemps & "\download.txt")
|
|
Dim lines1() As String = File.ReadAllLines(dostemps & "\download.txt")
|
|
Dim dl = lines1(0)
|
|
File.Delete(dostemps & "\download.txt")
|
|
fichiersetrouvelas = Form2.ListBox1.SelectedItem
|
|
téléchargement = 1
|
|
ProgressBar1.Show()
|
|
téléchargerfr = New WebClient
|
|
téléchargerfr.DownloadFileTaskAsync(New Uri(dl), (dostemps & "\" & Form2.ListBox1.SelectedItem & ".zip"))
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub téléchargerfr_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles téléchargerfr.DownloadProgressChanged
|
|
Label1.Show()
|
|
ProgressBar1.Value = e.ProgressPercentage
|
|
Label1.Text = String.Format("Téléchargement: " & e.ProgressPercentage & "% " & "{0} MB / {1} MB", (e.BytesReceived / 1024D / 1024D).ToString("0.00"), (e.TotalBytesToReceive / 1024D / 1024D).ToString("0.00"))
|
|
Me.Text = e.ProgressPercentage & "% téléchargement de: " & Form2.ListBox1.SelectedItem
|
|
End Sub
|
|
|
|
Private Sub téléchargerfr_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles téléchargerfr.DownloadFileCompleted
|
|
ProgressBar1.Value = 0
|
|
ProgressBar1.Style = ProgressBarStyle.Marquee
|
|
Me.Text = "finalisation du téléchargement de: " & Form2.ListBox1.SelectedItem
|
|
Label1.Text = "décomprétion du fichier..."
|
|
BackgroundWorker1.RunWorkerAsync()
|
|
End Sub
|
|
|
|
Dim WithEvents téléchargerfr As WebClient
|
|
|
|
Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
|
|
Try
|
|
IO.Compression.ZipFile.ExtractToDirectory(dostemps & "\" & fichiersetrouvelas & ".zip", FolderBrowserDialog1.SelectedPath & "/")
|
|
Catch ex As Exception
|
|
téléchargement = 0
|
|
File.Delete(dostemps & fichiersetrouvelas & ".zip")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
|
|
Label1.Hide()
|
|
File.Delete(dostemps & Form2.ListBox1.SelectedItem & ".zip")
|
|
téléchargement = 0
|
|
MsgBox("Le fichier: " & Form2.ListBox1.SelectedItem & " a bien êtê télécharger", MsgBoxStyle.Information)
|
|
Close()
|
|
End Sub
|
|
|
|
Private Sub Form25_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
If téléchargement = 1 Then
|
|
e.Cancel = True
|
|
MsgBox("Le téléchargement de: " & Form2.ListBox1.SelectedItem & " est en cours" & vbNewLine & vbNewLine & "merci de patienter", MsgBoxStyle.Exclamation)
|
|
Else
|
|
ProgressBar1.Style = ProgressBarStyle.Continuous
|
|
ProgressBar1.Value = 0
|
|
End If
|
|
End Sub
|
|
Sub fermer()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
|
|
ProgressBar1.Style = ProgressBarStyle.Continuous
|
|
ProgressBar1.Value = e.ProgressPercentage
|
|
End Sub
|
|
End Class |