Tuesday, November 22, 2011

Mengcopy Seluruh Folder Beserta Isinya - VB6 Source

Berikut merupakan contoh source code untuk mengcopy folder beserta seluruh isi yang terdapat di dalamnya. Menggunakan Microsoft Scripting Runtime. Untuk lebih memudahkan penggunaan Anda dapat merubahnya menjadi Function.

Sumber: http://www.i-bego.com/visual-basic/copy-folder-pada-vb-t3616.html

Private Sub CopyFolder() 
    Dim fso 
    Dim sfol As String, dfol As String 
    sfol = "c:\MyFolder" ' change to match the source folder path 
    dfol = "e:\MyFolder" ' change to match the destination  folder path 
    Set fso = CreateObject("Scripting.FileSystemObject") 
    If Not fso.FolderExists(dfol) Then 
        fso.CopyFolder sfol, dfol 
    Else 
        MsgBox dfol & " already exists!", vbExclamation, "Folder Exists" 
    End If 
End Sub