Sub FileCopyRecurse(ByVal Source As String, ByVal Destination As String, Optional ByVal Mask As String = "*")
Dim colSubDirs As Collection, V As Variant, F As String
Set colSubDirs = New Collection
F = Dir$(Source & "\" & Mask)
Do While Len(F) > 0
If (GetAttr(Source & "\" & F) And vbDirectory) = vbDirectory Then
On Error Resume Next
colSubDirs.Add F
On Error GoTo 0
Else
On Error Resume Next
FileCopy Source & "\" & F, Destination & "\" & F
On Error GoTo 0
End If
F = Dir$
Loop
For Each V In colSubDirs
MkDir Destination & "\" & V
FileCopyRecurse Source & "\" & V, Destination & "\" & V, Mask
Next
Set colSubDirs = Nothing
End Sub
Sub FileCopyRecurseFSO(ByVal Source As String, ByVal Destination As String)
Dim fso As FileSystemObject
fso.CopyFolder Source, Destination
Set fso = Nothing
End Sub
Sub FileCopyRecurseFSO(ByVal Source As String, ByVal Destination As String, Optional ByVal Mask As String = "*")
Dim fso As FileSystemObject
fso.CopyFile Source & "\" & Mask,Destination
Set fso = Nothing
End Sub
Sub FileCopyRecurseFSO(ByVal Source As String, ByVal Destination As String, Optional ByVal Mask As String = "*")
Dim fso As FileSystemObject, CurFolder As Folder, Folder As Folder, File As File
Set CurFolder = fso.GetFolder(Source)
For Each Folder In CurFolder.SubFolders
MkDir Destination & "\" & Folder.Name
FileCopyRecurseFSO Folder.Path, Destination & "\" & Folder.Name
Next Folder
For Each File In CurFolder.Files
If File.Name Like Mask Then
File.Copy Destination
End If
Next
Set fso = Nothing
End Sub
Сейчас этот форум просматривают: AhrefsBot и гости: 55