Add the following objects to a new project:Name Value Description
FO_COPY &H2 Copies a file or folder
FO_DELETE &H3 Deletes a file or folder
FO_MOVE &H1 Moves a file or folder
FO_RENAME &H4 Renames a file or folder
FOF_ALLOWUNDO &H40 Used with Rename. When used with Delete the files get sent to the Recycle Bin.
FOF_FILESONLY &H80 Only allows files.
FOF_NOCONFIRMATION &H10 Does not display the Delete or Overwrite confirmation dialog.
FOF_SILENT &H4 Does not display the Windows animation while performing the opperation.
FOF_SIMPLEPROGRESS &H100 Does not display filenames
Add the following to a new module
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, sets dialog title
End Type
Public Const FO_COPY = &H2 ' Copy File/Folder
Public Const FO_DELETE = &H3 ' Delete File/Folder
Public Const FO_MOVE = &H1 ' Move File/Folder
Public Const FO_RENAME = &H4 ' Rename File/Folder
Public Const FOF_ALLOWUNDO = &H40 ' Allow to undo rename, delete ie sends to recycle bin
Public Const FOF_FILESONLY = &H80 ' Only allow files
Public Const FOF_NOCONFIRMATION = &H10 ' No File Delete or Overwrite Confirmation Dialog
Public Const FOF_SILENT = &H4 ' No copy/move dialog
Public Const FOF_SIMPLEPROGRESS = &H100 ' Does not display file names
Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
____________________________________________
This will copy c:\backup to c:\backup2 and will not show filenames:
Dim op As SHFILEOPSTRUCT
With op
.wFunc = FO_COPY ' Set function
.pTo = "C:\backup2" ' Set new path
.pFrom = "C:\backup" ' Set current path
.fFlags = FOF_SIMPLEPROGRESS
End With
' Perform operation
SHFileOperation op