Copying Folder and its Sub-directories

b_karv

Registered User.
Local time
Today, 07:17
Joined
Sep 15, 2004
Messages
31
Hi Everyone,

I am wandering if anyone can give me hand in coding this problem. I need to copy a folder & all its sub-directories(and files) to another destination. I have tried various codes floating around on the net but only for them not too work.

I would greatly appreciate if anyone can help me do this in Access 2002.

Thank you.

Kind Regards,

Karvan
 
Karvan,

Why not just use the Shell command and start XCOPY?

Wayne
 
Thanks for that but not 2 bother now, I ended making a bat file instead to the do copy, which I then call via macro in Access


Cheers

Karv
 
This is what I use to back up a folder I store files in:
"images" is the folder I am backing up. It is located in the same folder as the database. The code copies the folder and names it "External_File Backup-" plus the date in the "Backup" folder.

Code:
Dim fso
Dim sfol As String, dfol As String
Dim pathx As String
Dim path As String
Dim dt As Date
Dim pathloc As String
Dim pathb As String
Dim strDayPrefix As String

path = Me.Application.CurrentProject.path
pathx = Me.Application.CurrentProject.path & "\Images"
pathb = path & "\backups\"

strDayPrefix = Format(Date, "mm-dd-yyyy")
pathloc = "External_File Backup-" & strDayPrefix

sfol = pathx ' change to match the source folder path
dfol = pathb & pathloc ' 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
 

Users who are viewing this thread

Back
Top Bottom