[RESOLVED] Backup folder .....Overwrite
hi all ...
any one know how to Copy a complete folder to other folder without Overwrite message ?
i use this module ...
Code:
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 Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
' Available Operations
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
' Flags
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 Sub VBCopyFolder(ByRef strSource As String, ByRef strTarget As String)
Dim op As SHFILEOPSTRUCT
With op
.wFunc = FO_COPY ' Set function
.pTo = strTarget ' Set new path
.pFrom = strSource ' Set current path
.fFlags = FOF_SIMPLEPROGRESS
End With
' Perform operation
SHFileOperation op
End Sub
and this code
Code:
Private Sub Command1_Click()
Call VBCopyFolder("C:\TEST", "C:\files")
End Sub
this one work but when i do another backup for a folder it give overwrite message .... i dont need this message ...i cant every time click overwite ... because this will work as a backup ...
please help ...
regards
Re: Backup folder .....Overwrite
You have the answer right in your code:
Public Const FOF_NOCONFIRMATION = &H10 ' No File Delete or Overwrite Confirmation Dialog
so just add that flag:
Code:
With op
.wFunc = FO_COPY ' Set function
.pTo = strTarget ' Set new path
.pFrom = strSource ' Set current path
.fFlags = FOF_SIMPLEPROGRESS Or FOF_NOCONFIRMATION
End With
Re: Backup folder .....Overwrite