Imports System.ComponentModel
Imports System.IO

Public Class Form8
    Public nombredeserver As Integer = 0
    Public servercn As Integer = 0
    Public proselect = Form4.profilselect
    Public selectser = ""
    Public zip2 As Integer = 0
    Dim heursa = ""
    Dim import = 0
    Private Sub Form8_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        BackColor = Form4.BackColor
        ForeColor = Form4.ForeColor
        Dim lines1() As String = File.ReadAllLines(dosparasetting & "/stopauto.txt")
        If lines1(0) = 0 Then
            CheckBox1.Checked = False
        Else
            CheckBox1.Checked = True
        End If
        CheckBox1.Hide()
        servercn = 0
        proselect = Form4.profilselect
        selectser = ""
        zip2 = 0
        heursa = ""
        import = 0
        OpenFileDialog1.FileName = ""
        FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop
        ListBox1.Items.Clear()
        ListBox1.Hide()
        Text = proselect

        For Each fichier As String In IO.Directory.GetFiles(profil & "/" & Form4.profilselect & "/serveur/")
            Dim info As New IO.FileInfo(fichier)
            ListBox1.Items.Add(info.Name.ToString.Replace(".txt", ""))
        Next
        If ListBox1.Items.Count = 0 Then
            MsgBox("Aucun serveur trouver, merci de modifier le profil: " & Form4.profilselect, MsgBoxStyle.Exclamation)
            Close()
        Else
            nombredeserver = ListBox1.Items.Count
            startbc()
        End If
    End Sub
    Sub startbc()
        If servercn <= ListBox1.Items.Count - 1 Then
            ListBox1.SelectedIndex = servercn
            selectser = ListBox1.SelectedItem
            Dim msg = MsgBox("le serveur: " & ListBox1.SelectedItem & " est t'il ZIPER", MsgBoxStyle.YesNoCancel)
            If msg = MsgBoxResult.Yes Then
                If OpenFileDialog1.ShowDialog = 1 Then
                    import = 1
                    Label1.Text = "importation de: " & OpenFileDialog1.SafeFileName
                    ProgressBar1.Style = ProgressBarStyle.Marquee
                    zip2 = 0
                    Directory.CreateDirectory(profil & "/" & Form4.profilselect & "/tmp/" & ListBox1.SelectedItem & "/")
                    BackgroundWorker1.RunWorkerAsync()
                Else
                    startbc()
                End If
            ElseIf msg = MsgBoxResult.No Then
                If FolderBrowserDialog1.ShowDialog = 1 Then
                    import = 1
                    Label1.Text = "importation de: " & FolderBrowserDialog1.SelectedPath
                    ProgressBar1.Style = ProgressBarStyle.Marquee
                    zip2 = 1
                    Directory.CreateDirectory(profil & "/" & Form4.profilselect & "/tmp/" & ListBox1.SelectedItem & "/")
                    BackgroundWorker2.RunWorkerAsync()
                Else
                    startbc()
                End If
            Else
                If Directory.Exists(profil & proselect & "/tmp/") = True Then
                    For Each fichier1 As String In IO.Directory.GetDirectories(profil & proselect & "/tmp/")
                        Dim info As New IO.FileInfo(fichier1)
                        Directory.Delete(fichier1, recursive:=True)
                    Next
                    Directory.Delete(profil & proselect & "/tmp/")
                End If
                Close()
            End If
        Else
            import = 2
            ProgressBar1.Style = ProgressBarStyle.Marquee
            startbcfinal()
        End If
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Compression.ZipFile.ExtractToDirectory(OpenFileDialog1.FileName, profil & proselect & "/tmp/" & selectser & "/")
        If zip2 = 1 Then
            File.Delete(OpenFileDialog1.FileName)
        End If
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        servercn = servercn + 1
        ProgressBar1.Style = ProgressBarStyle.Continuous
        ProgressBar1.Value = 100
        import = 0
        startbc()
    End Sub

    Private Sub BackgroundWorker2_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker2.DoWork
        Compression.ZipFile.CreateFromDirectory(FolderBrowserDialog1.SelectedPath, profil & proselect & "/tmp/" & selectser & ".zip")
    End Sub

    Private Sub BackgroundWorker2_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker2.RunWorkerCompleted
        OpenFileDialog1.FileName = profil & proselect & "/tmp/" & selectser & ".zip"
        Directory.CreateDirectory(profil & "/" & Form4.profilselect & "/tmp/" & ListBox1.SelectedItem & "/")
        BackgroundWorker1.RunWorkerAsync()
    End Sub
    Sub startbcfinal()
        Label1.Text = "création de la sauvegarde...."
        If TimeOfDay.Hour = "0" And TimeOfDay.Minute = "0" Then
            heursa = "00" & "h" & "00"
        ElseIf TimeOfDay.Hour = "0" And TimeOfDay.Minute = "1" Then
            heursa = "00" & "h" & "01"
        ElseIf TimeOfDay.Hour = "0" And TimeOfDay.Minute = "2" Then
            heursa = "00" & "h" & "02"
        ElseIf TimeOfDay.Hour = "0" And TimeOfDay.Minute = "3" Then
            heursa = "00" & "h" & "03"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "4" Then
            heursa = "00" & "h" & "04"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "5" Then
            heursa = "00" & "h" & "05"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "6" Then
            heursa = "00" & "h" & "06"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "7" Then
            heursa = "00" & "h" & "07"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "8" Then
            heursa = "00" & "h" & "08"
        ElseIf TimeOfDay.Hour = "00" And TimeOfDay.Minute = "9" Then
            heursa = "00" & "h" & "09"
        ElseIf TimeOfDay.Hour = "0" Then
            heursa = "00" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "0" Then
            heursa = "01" & "h" & "00"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "1" Then
            heursa = "01" & "h" & "01"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "2" Then
            heursa = "01" & "h" & "02"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "3" Then
            heursa = "01" & "h" & "03"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "4" Then
            heursa = "01" & "h" & "04"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "5" Then
            heursa = "01" & "h" & "05"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "6" Then
            heursa = "01" & "h" & "06"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "7" Then
            heursa = "01" & "h" & "07"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "8" Then
            heursa = "01" & "h" & "08"
        ElseIf TimeOfDay.Hour = "1" And TimeOfDay.Minute = "9" Then
            heursa = "01" & "h" & "09"
        ElseIf TimeOfDay.Hour = "1" Then
            heursa = "01" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "0" Then
            heursa = "02" & "h" & "00"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "1" Then
            heursa = "02" & "h" & "01"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "2" Then
            heursa = "02" & "h" & "02"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "3" Then
            heursa = "02" & "h" & "03"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "4" Then
            heursa = "02" & "h" & "04"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "5" Then
            heursa = "02" & "h" & "05"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "6" Then
            heursa = "02" & "h" & "06"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "7" Then
            heursa = "02" & "h" & "07"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "8" Then
            heursa = "02" & "h" & "08"
        ElseIf TimeOfDay.Hour = "2" And TimeOfDay.Minute = "9" Then
            heursa = "02" & "h" & "09"
        ElseIf TimeOfDay.Hour = "2" Then
            heursa = "02" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "0" Then
            heursa = "03" & "h" & "00"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "1" Then
            heursa = "03" & "h" & "01"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "2" Then
            heursa = "03" & "h" & "02"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "3" Then
            heursa = "03" & "h" & "03"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "4" Then
            heursa = "03" & "h" & "04"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "5" Then
            heursa = "03" & "h" & "05"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "6" Then
            heursa = "03" & "h" & "06"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "7" Then
            heursa = "03" & "h" & "07"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "8" Then
            heursa = "03" & "h" & "08"
        ElseIf TimeOfDay.Hour = "3" And TimeOfDay.Minute = "9" Then
            heursa = "03" & "h" & "09"
        ElseIf TimeOfDay.Hour = "3" Then
            heursa = "03" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "0" Then
            heursa = "04" & "h" & "00"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "1" Then
            heursa = "04" & "h" & "01"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "2" Then
            heursa = "04" & "h" & "02"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "3" Then
            heursa = "04" & "h" & "03"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "4" Then
            heursa = "04" & "h" & "04"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "5" Then
            heursa = "04" & "h" & "05"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "6" Then
            heursa = "04" & "h" & "06"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "7" Then
            heursa = "04" & "h" & "07"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "8" Then
            heursa = "04" & "h" & "08"
        ElseIf TimeOfDay.Hour = "4" And TimeOfDay.Minute = "9" Then
            heursa = "04" & "h" & "09"
        ElseIf TimeOfDay.Hour = "4" Then
            heursa = "04" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "0" Then
            heursa = "05" & "h" & "00"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "1" Then
            heursa = "05" & "h" & "01"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "2" Then
            heursa = "05" & "h" & "02"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "3" Then
            heursa = "05" & "h" & "03"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "4" Then
            heursa = "05" & "h" & "04"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "5" Then
            heursa = "05" & "h" & "05"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "6" Then
            heursa = "05" & "h" & "06"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "7" Then
            heursa = "05" & "h" & "07"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "8" Then
            heursa = "05" & "h" & "08"
        ElseIf TimeOfDay.Hour = "5" And TimeOfDay.Minute = "9" Then
            heursa = "05" & "h" & "09"
        ElseIf TimeOfDay.Hour = "5" Then
            heursa = "05" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "0" Then
            heursa = "06" & "h" & "00"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "1" Then
            heursa = "06" & "h" & "01"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "2" Then
            heursa = "06" & "h" & "02"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "3" Then
            heursa = "06" & "h" & "03"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "4" Then
            heursa = "06" & "h" & "04"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "5" Then
            heursa = "06" & "h" & "05"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "6" Then
            heursa = "06" & "h" & "06"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "7" Then
            heursa = "06" & "h" & "07"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "8" Then
            heursa = "06" & "h" & "08"
        ElseIf TimeOfDay.Hour = "6" And TimeOfDay.Minute = "9" Then
            heursa = "06" & "h" & "09"
        ElseIf TimeOfDay.Hour = "6" Then
            heursa = "06" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "0" Then
            heursa = "07" & "h" & "00"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "1" Then
            heursa = "07" & "h" & "01"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "2" Then
            heursa = "07" & "h" & "02"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "3" Then
            heursa = "07" & "h" & "03"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "4" Then
            heursa = "07" & "h" & "04"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "5" Then
            heursa = "07" & "h" & "05"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "6" Then
            heursa = "07" & "h" & "06"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "7" Then
            heursa = "07" & "h" & "07"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "8" Then
            heursa = "07" & "h" & "08"
        ElseIf TimeOfDay.Hour = "7" And TimeOfDay.Minute = "9" Then
            heursa = "07" & "h" & "09"
        ElseIf TimeOfDay.Hour = "7" Then
            heursa = "07" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "0" Then
            heursa = "08" & "h" & "00"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "1" Then
            heursa = "08" & "h" & "01"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "2" Then
            heursa = "08" & "h" & "02"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "3" Then
            heursa = "08" & "h" & "03"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "4" Then
            heursa = "08" & "h" & "04"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "5" Then
            heursa = "08" & "h" & "05"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "6" Then
            heursa = "08" & "h" & "06"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "7" Then
            heursa = "08" & "h" & "07"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "8" Then
            heursa = "08" & "h" & "08"
        ElseIf TimeOfDay.Hour = "8" And TimeOfDay.Minute = "9" Then
            heursa = "08" & "h" & "09"
        ElseIf TimeOfDay.Hour = "8" Then
            heursa = "08" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "0" Then
            heursa = "09" & "h" & "00"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "1" Then
            heursa = "09" & "h" & "01"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "2" Then
            heursa = "09" & "h" & "02"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "3" Then
            heursa = "09" & "h" & "03"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "4" Then
            heursa = "09" & "h" & "04"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "5" Then
            heursa = "09" & "h" & "05"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "6" Then
            heursa = "09" & "h" & "06"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "7" Then
            heursa = "09" & "h" & "07"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "8" Then
            heursa = "09" & "h" & "08"
        ElseIf TimeOfDay.Hour = "9" And TimeOfDay.Minute = "9" Then
            heursa = "09" & "h" & "09"
        ElseIf TimeOfDay.Hour = "9" Then
            heursa = "09" & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "00" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "10" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "10" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "11" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "11" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "12" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "12" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "13" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "13" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "14" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "14" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "15" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "15" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "16" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "16" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "17" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "17" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "18" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "18" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "19" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "19" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "20" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "20" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "21" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "21" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "22" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "22" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "0" Then
            heursa = TimeOfDay.Hour & "h" & "00"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "1" Then
            heursa = TimeOfDay.Hour & "h" & "01"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "2" Then
            heursa = TimeOfDay.Hour & "h" & "02"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "3" Then
            heursa = TimeOfDay.Hour & "h" & "03"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "4" Then
            heursa = TimeOfDay.Hour & "h" & "04"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "5" Then
            heursa = TimeOfDay.Hour & "h" & "05"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "6" Then
            heursa = TimeOfDay.Hour & "h" & "06"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "7" Then
            heursa = TimeOfDay.Hour & "h" & "07"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "8" Then
            heursa = TimeOfDay.Hour & "h" & "08"
        ElseIf TimeOfDay.Hour = "23" And TimeOfDay.Minute = "9" Then
            heursa = TimeOfDay.Hour & "h" & "09"
        ElseIf TimeOfDay.Hour = "23" Then
            heursa = TimeOfDay.Hour & "h" & TimeOfDay.Minute
        End If
        CheckBox1.Show()
        BackgroundWorker3.RunWorkerAsync()
    End Sub

    Private Sub BackgroundWorker3_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork
        Compression.ZipFile.CreateFromDirectory(profil & proselect & "/tmp/", profil & proselect & "/Backup/" & proselect & " " & Today.Day & "-" & Today.Month & "-" & Today.Year & " à " & heursa & ".zip")
    End Sub

    Private Sub BackgroundWorker3_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker3.RunWorkerCompleted
        Label1.Text = "supprétion des fichiers TEMP..."
        BackgroundWorker4.RunWorkerAsync()
    End Sub

    Private Sub Form8_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
        If import = 1 Then
            e.Cancel = True
            MsgBox("merci de patianter pandent l'importation", MsgBoxStyle.Exclamation)
        ElseIf import = 2 Then
            e.Cancel = True
            MsgBox("merci de patianter pandent la création de la sauvegarde", MsgBoxStyle.Exclamation)
        Else
            nombredeserver = 0
            servercn = 0
            proselect = Form4.profilselect
            selectser = ""
            zip2 = 0
            heursa = ""
            import = 0
            OpenFileDialog1.FileName = ""
            FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop
        End If

    End Sub

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
        MsgBox(Label1.Text, MsgBoxStyle.Information)
    End Sub

    Private Sub BackgroundWorker4_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker4.DoWork
        For Each fichier1 As String In IO.Directory.GetDirectories(profil & proselect & "/tmp/")
            Dim info As New IO.FileInfo(fichier1)
            Directory.Delete(fichier1, recursive:=True)
        Next
        Directory.Delete(profil & proselect & "/tmp/")
    End Sub

    Private Sub BackgroundWorker4_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker4.RunWorkerCompleted
        ProgressBar1.Style = ProgressBarStyle.Continuous
        ProgressBar1.Value = 100
        import = 0
        If CheckBox1.Checked = True Then
            CheckBox1.Hide()
            Form12.ShowDialog()
            Close()
        Else
            CheckBox1.Hide()
            MsgBox("Sauvagarde terminer", MsgBoxStyle.Information)
            Close()
        End If
    End Sub
End Class