huggo1
Messages postés3Date d'inscriptionsamedi 4 octobre 2014StatutMembreDernière intervention10 mai 2015
-
10 mai 2015 à 19:49
huggo1
Messages postés3Date d'inscriptionsamedi 4 octobre 2014StatutMembreDernière intervention10 mai 2015
-
10 mai 2015 à 20:16
Bonjour,
Je souhaite copier des fichiers texte qui se trouvent dans un dossier vers une clé USB.
Je me perds un peu dans toutes ces lignes.
Un petit coup de main serait le bienvenue.
Merci d'avance.
Dim path1 As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Backup Of Files\"
Dim theFiles() As String = System.IO.Directory.GetFiles(path1, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
For Each currentFile As String In theFiles
Try
For Each drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
If drive.DriveType = IO.DriveType.Removable AndAlso drive.IsReady Then
Dim DriveLetter As String = drive.Name
Dim PathToUSBDrive = DriveLetter & IO.Path.GetFileName(currentFile)
My.Computer.FileSystem.CopyFile(currentFile, PathToUSBDrive, True)
End If
Next
Catch ex As Exception
End Try
Next
Dim MyDoc As New IO.FileInfo(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Backup Of Files\test\")
For Each foundFile As String In My.Computer.FileSystem.GetFiles(MyDoc.Directory.FullName, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
Try
For Each drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
If drive.DriveType = IO.DriveType.Removable AndAlso drive.IsReady Then ' AndAlso drive.AvailableFreeSpace >= 2 * Gig Then
Dim DriveLetter As String = drive.Name
Dim PathToUSBDrive = DriveLetter & IO.Path.GetFileName(foundFile)
My.Computer.FileSystem.CopyFile(foundFile, PathToUSBDrive, True)
End If
Next
Catch ex As Exception
End Try
Next