Good day!.

I want to copy all the folder contents to a certain location. To be specific, i have a folder named (webproject) relative on my vb program path.When the form load, i want to copy all the content of this folder(webproject) to C:\wamp\wwww\onlineweb\.I just really dont know how to start the coding. If someone can help me to solve this problem thank you very many much

God bless on this mother earth.

Recommended Answers

All 5 Replies

I have always loved the power of API's :D

This will help you...

Private Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

'~~> Copy File/Folder
Private Const FO_COPY = &H2
'~~> Does not display file names
Private Const FOF_SIMPLEPROGRESS = &H100

Private 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
End Type

Private Sub VBCopyFolder(ByRef strSource As String, ByRef strTarget As String)
    Dim op As SHFILEOPSTRUCT
    With op
        .wFunc = FO_COPY
        .pTo = strTarget
        .pFrom = strSource
        .fFlags = FOF_SIMPLEPROGRESS
    End With
    
    '~~> Perform operation
    SHFileOperation op
End Sub

Private Sub Command1_Click()
    '~~> Copy Folder C:\temp\1 to C:\temp\2
    '~~> Change this to relevant folders
    Call VBCopyFolder("C:\temp\1", "C:\temp\2")
End Sub

name oldfile as newfile

will do the same...

Good Luck

Thank you guys. I havent try it yet. I will do this now. I know this will work.as i can look at the code. I have read thid API already. I will mark this problem solved.

Thank you very much guys again. Hope to see you all on next thread.!

God bless on this mother earth.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.