VB Code:
Option Explicit 'Add a command button Private Type SHFILEOPSTRUCT hWnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAborted As Boolean hNameMaps As Long sProgress As String End Type Private Const FO_MOVE As Long = &H1 Private Const FO_COPY As Long = &H2 Private Const FO_DELETE = &H3 Private Const FO_RENAME As Long = &H4 Private Const FOF_ALLOWUNDO = &H40 Private Const FOF_SIMPLEPROGRESS As Long = &H100 Private Const FOF_NOCONFIRMATION As Long = &H10 Private Const FOF_NOCONFIRMMKDIR As Long = &H200 Private Const FOF_NOERRORUI As Long = &H400 Private Const FOF_RENAMEONCOLLISION As Long = &H8 Private Const FOF_SILENT As Long = &H4 Private Const FOF_WANTNUKEWARNING As Long = &H4000 Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Private Sub Form_Load() Dim SHFileOp As SHFILEOPSTRUCT With SHFileOp .wFunc = FO_COPY .pFrom = "C:\pb" 'Select a folder and all its subdirectories/files .pTo = "C:\Program Files\EA GAMES" 'You can also rename the file if you want of leave it the same .fFlags = FOF_NOCONFIRMATION End With 'perform file operation SHFileOperation SHFileOp End Sub
I did that and it didn't overwrite the folder, it just put my contents from the C:\pb folder into the other one.




Reply With Quote