Copying directories

M

Mike J. Soames

Hi All,
I am trying to write a vba function to put in Access that
will in affect backup a couple of directories to another
machine. The directories i need to copy contain several
layers of sub directories.
I did write a system that did this a few years back, but
have since lost the code, it utalised nested loops and
worked as follows (as I could remember)
First it searched the given path using the dir statment
to find the directories, then it built that directory
structure onto the other disk, next it went into each of
the directories and looked for sub directories, if there
where any it built them, and so forth. Each time it
produced a directory it copied the files from the source
to the target.
Im a bit dubious about the nested calls as they can cause
big problems.
Has anyone any hints or even better a link to some code
that would achive the objective without all the fuss.

Thanks for your time

Mike J. Soames
 
G

Guest

Try this:
1. Make a reference to the "Microsoft Scripting Runtime"
library.

2. Use the following code to make a copy of you folders:

Set wshFSO = New Scripting.FileSystemObject
wshFSO.CopyFolder "Source", "Destination", True

This copies the folder "Source" and all its content
(including subfolders) to the folder "Destination".
Both, "Source" and "Destination" parameters are string
values, containing the FullFolderNames (including drive
and path). You are allowed to use URL names.

Hope this works for you, it does for me!

Philip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top