Вот пример того, как перемещать каталоги:
Dim sSourcePath As String
Dim sDestPath As String
Dim sTextToFind As String
sSourcePath = "D:\Temp"
sDestPath = "D:\Temp1"
sTextToFind = "test"
For Each sDir In Directory.GetDirectories(sSourcePath, "*" & sTextToFind & "*")
Directory.Move(sDir, Path.Combine(sDestPath, Path.GetFileName(sDir)))
Next
Чтобы скопировать все файлы в папках, цикл можно изменить на:
Dim sFullDestDir As String
sFullDestDir = Path.Combine(sDestPath, IO.Path.GetFileName(sFullSourceDir))
' Create the directory if it doesn't exist
If Not Directory.Exists(sFullDestDir) Then
Directory.CreateDirectory(sFullDestDir)
End If
' Copy the files in the directory
' If subfolders are to be copied, this logic can be turned into a recursive method.
For Each sFileName As String In Directory.GetFiles(sFullSourceDir)
File.Copy(sFileName, Path.Combine(sFullDestDir, IO.Path.GetFileName(sFileName)))
Next