1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| 'Variables mises au début de la Class
Dim Drive As String = SelectDrives.ComboBox1.SelectedItem 'Drive = la lettre que l'on sélectionne dans la combobox
Dim NomPC As String = Environment.MachineName 'variable d'environnement qui donne le nom du pc
Sub Copie_Docs()
Dim di As New DirectoryInfo(Profil)
Dim NomProfil As String = di.Name
Dim Profildestination As String = (Drive & NomPC & "\Profils\" & NomProfil & "\")
Dim _f As New DirectoryInfo("Mon Path")
If Directory.Exists(Users & "\" & NomProfil & "\Documents") Then
My.Computer.FileSystem.CreateDirectory(Drive & NomPC & "\Profils\" & NomProfil & "\Documents")
Try
If (_f.Attributes And FileAttributes.System) = FileAttributes.System Then
Continue For
Else
My.Computer.FileSystem.CopyDirectory(Users & "\" & NomProfil & "\Documents", Profildestination & "\Documents", True)
End If
Catch erreur As Exception
My.Computer.FileSystem.WriteAllText(Drive & NomPC & "\Erreurs.txt", vbCrLf & "-" & erreur.Message & vbCrLf, True)
End Try
Next
End Sub |
Partager