Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Long
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_DELETE = &H3
Dim Dro
Dim DS As String
Dim DW As String
Dim MM
Dim portable
Dim DD
Dim NewSer As String
Dim prompt As String
Dim DFolder As String
Dim Dpath As String
Dim m, d
Dim XX As String
Dim lngReturn As Long
Dim SHFileOp As SHFILEOPSTRUCT
Public Sub CopyFolder(ByVal Source As String, ByVal Dest As String)
'On Error GoTo errorhanlder
Const FO_COPY As Long = &H2
Const FOF_NOCONFIRMATION As Long = &H10
Const FOF_CREATEPROGRESSDLG As Long = &H0
Const FOF_NOCONFIRMMKDIR As Long = &H200
'new bit to keep silent and just return arror number
Const FOF_SILENT As Long = &H4
'-------------------------------------------------
Const FILE_FLAGS = FOF_NOCONFIRMATION Or FOF_CREATEPROGRESSDLG Or FOF_NOCONFIRMMKDIR Or FOF_SILENT
Dim typFO As SHFILEOPSTRUCT
With typFO
.wFunc = FO_COPY
.fFlags = FILE_FLAGS
.pFrom = Source
.pTo = Dest
End With
lngReturn = SHFileOperation(typFO)
'MsgBox SHFileOperation(fAnyOperationsAborted)
'errorhanlder:
' MsgBox Err.Number
End Sub
Private Sub Form_Load()
CopyFolder "c:\windowsggg", "F:\New Folder'this will creat error for the function
If lngReturn = "1026" Then
MsgBox "problem with file"
End If
If lngReturn = "1223" Then
MsgBox "canceled"
End If
End Sub