Public Enum FO_Operation
FO_MOVE = 1
FO_COPY = 2
FO_DELETE = 3
FO_RENAME = 4
End Enum
Public Enum FOFlags
FOF_MULTIDESTFILES = &H1 'Destination specifies multiple files
FOF_SILENT = &H4 'Don't display progress dialog
FOF_RENAMEONCOLLISION = &H8 'Rename if destination already exists
FOF_NOCONFIRMATION = &H10 'Don't prompt user
FOF_WANTMAPPINGHANDLE = &H20 'Fill in hNameMappings member
FOF_ALLOWUNDO = &H40 'Store undo information if possible
FOF_FILESONLY = &H80 'On *.*, don't copy directories
FOF_SIMPLEPROGRESS = &H100 'Don't show name of each file
FOF_NOCONFIRMMKDIR = &H200 'Don't confirm making any needed dirs
End Enum
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long ' only used if FOF_SIMPLEPROGRESS
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private op As SHFILEOPSTRUCT
public sub FolderCopy (sSourcePath as string, sDestPath as string)
with Op
.wFunc = FO_COPY
.pfrom = "c:\temp\*.*"
.pto = "d:\temp2\*.*"
.flags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR
end with
Private Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMMKDIR = &H200
Private Sub Command1_Click()
Dim SHFileOp As SHFileOperation
SHFileOp.wfunc = FO_COPY
SHFileOp.pfrom = "c\temp\*.*"
SHFileOp.pto = "c\temp2\*.*"
shefilop.flags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR
SHFileOperation SHFileOp
End Sub