There are some similar posts about this topic, I know. However, I have a code which is different than all codes I have seen here (when talking about this subject).
The e
To copy all files and sub-folders recursively, use the following code:
Public Sub CopyDirectory(ByVal source As String, ByVal destination As String)
Dim fso, file, folder As Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Delete existing folder
If fso.FolderExists(destination) Then fso.DeleteFolder destination, True
fso.CreateFolder destination
For Each file in fso.GetFolder(source).files
fso.CopyFile file.Path, destination & "\" & file.Name
Next file
For Each folder in fso.GetFolder(source).SubFolders
CopyDirectory folder.Path, destination & "\" & folder.Name
Next folder
End Sub
Use as following:
CopyFile "C:\Path To Source", "C:\Path to destination"
Note that the paths should not include a trailing directory separator (\).