Imports System.ComponentModel Imports System.IO Public Class Form202 Dim dl As Integer Public azerty As Integer = 0 Dim nom As String = "" Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork dl = 1 Dim sw1 As New StreamWriter(dosprofils & nomprofils & "\nom.txt") sw1.WriteLine(nomprofils) sw1.Close() IO.Compression.ZipFile.CreateFromDirectory(dosprofils & nomprofils, FolderBrowserDialog1.SelectedPath & "\exportation du profil de " & nomprofils & ".zip") End Sub Private Sub Form202_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim lines1() As String = File.ReadAllLines(théme) If lines1(0) = 2 Then Me.BackColor = Color.FromArgb(64, 64, 64) ProgressBar1.BackColor = Color.FromArgb(64, 64, 64) ElseIf lines1(0) = 3 Then Me.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB) ProgressBar1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB) End If If azerty = 0 Then If FolderBrowserDialog1.ShowDialog = 1 Then If File.Exists(FolderBrowserDialog1.SelectedPath & "\exportation du profil de " & nomprofils & ".zip") = True Then MsgBox("Le fichier exister déjà merci de sélectionnez un autre dossier", MsgBoxStyle.Exclamation) Close() Else Me.Text = "Exportation du profil: " & nomprofils BackgroundWorker1.RunWorkerAsync() End If Else Close() End If Else If OpenFileDialog1.ShowDialog = 1 Then dl = 1 Me.Text = "Recherche du profil..." BackgroundWorker2.RunWorkerAsync() Else MsgBox("Merci de sélectionnez un profil", MsgBoxStyle.Exclamation) Close() End If End If End Sub Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted File.Delete(dosprofils & nomprofils & "\nom.txt") dl = 0 MsgBox("Exportation du profil: " & nomprofils & " est terminer", MsgBoxStyle.Information) Close() End Sub Private Sub Form202_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing If dl = 1 Then e.Cancel = True If azerty = 0 Then MsgBox("L’exportation du profil de: " & nomprofils & " est en cours" & vbNewLine & "merci de patienter", MsgBoxStyle.Exclamation) Else MsgBox("Une importation est en cours" & vbNewLine & "merci de pantienter", MsgBoxStyle.Exclamation) End If End If End Sub Private Sub BackgroundWorker2_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker2.DoWork Directory.CreateDirectory(dosprofils & "\temp\") IO.Compression.ZipFile.ExtractToDirectory(OpenFileDialog1.FileName, dosprofils & "\temp\") End Sub Private Sub BackgroundWorker3_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork Dim lines1() As String = File.ReadAllLines(dosprofils & "\temp\nom.txt") IO.Compression.ZipFile.ExtractToDirectory(OpenFileDialog1.FileName, dosprofils & lines1(0)) nom = lines1(0) End Sub Private Sub BackgroundWorker2_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker2.RunWorkerCompleted Dim lines1() As String = File.ReadAllLines(dosprofils & "\temp\nom.txt") If Directory.Exists(dosprofils & lines1(0)) = True Then dl = 0 MsgBox("Le profil: " & lines1(0) & " existe déjà", MsgBoxStyle.Exclamation) For Each fichier As String In IO.Directory.GetFiles(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier) File.Delete(fichier) Next For Each fichier1 As String In IO.Directory.GetDirectories(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier1) Directory.Delete(fichier1, recursive:=True) Next Directory.Delete(dosprofils & "\temp\") Close() Else Try Directory.CreateDirectory(dosprofils & lines1(0)) Me.Text = "Importation du profil: " & lines1(0) BackgroundWorker3.RunWorkerAsync() Catch ex As Exception For Each fichier As String In IO.Directory.GetFiles(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier) File.Delete(fichier) Next For Each fichier1 As String In IO.Directory.GetDirectories(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier1) Directory.Delete(fichier1, recursive:=True) Next Directory.Delete(dosprofils & "\temp\") dl = 0 MsgBox("Le profil est corrompu", MsgBoxStyle.Exclamation) Close() End Try End If End Sub Private Sub BackgroundWorker3_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker3.RunWorkerCompleted For Each fichier As String In IO.Directory.GetFiles(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier) File.Delete(fichier) Next For Each fichier1 As String In IO.Directory.GetDirectories(dosprofils & "\temp\") Dim info As New IO.FileInfo(fichier1) Directory.Delete(fichier1, recursive:=True) Next Directory.Delete(dosprofils & "\temp\") File.Delete(dosprofils & nom & "\nom.txt") ComboBox1.Items.Clear() For Each fichier As String In IO.Directory.GetDirectories(dosprofils) Dim info As New IO.DirectoryInfo(fichier) ComboBox1.Items.Add(info.Name) Next coutprofils = ComboBox1.Items.Count Form3.Label43.Text = "Nombre de profils: " & coutprofils ComboBox1.Items.Remove(nomprofils) If ComboBox1.Items.Count = 0 Then Form1.ChangerDeProfilsToolStripMenuItem.Visible = False Else Form1.ChangerDeProfilsToolStripMenuItem.Visible = True End If ComboBox1.Items.Clear() MsgBox("Le profil: " & nom & " a bien été importer", MsgBoxStyle.Information) dl = 0 Close() End Sub End Class