Results 1 to 3 of 3

Thread: [RESOLVED] Backup folder .....Overwrite

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    84

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    84

    Re: Backup folder .....Overwrite

    thanks man

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width