--
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Beny" <Be...@discussions.microsoft.com> wrote in message
news:E7B3AC08-5B7F-43A7...@microsoft.com...
: Hi everybody,
:
: I need a VB6 program to copy a whole directory ( sub-folders and all
: the files in) to another directory. I developped it using classes and
: collections ( for folders and files in ) but it's too long.
:
: Is there a better way please?. Sorry but I am not a VB6 guru. At least
could
: anyone put me on the proper track please?
:
: Otherwise I would gladly buy such a program.
:
: Thanks a lot
:
: Beny
:
:
You can find the class on my website: www.VBTricks.de.vu in the section
VB->components->clsFileOperations
Hoe this helps,
Stefan
--
___________________________________www.VBTricks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects
www: http://www.VBTricks.de.vu
mail: vbtricks <at> my-mail <dot> ch
_____________________________________________________
dim fso as object
dim copyfile as string
dim desteny as string
copyfile = "directory\*" or copyfile="file location"
destino = "final directory"
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.copyfile copyfile, desteny, True
Set FSO = Nothing
hope this helps...
A note please. You indicated:
FSO.copyfile copyfile, desteny, True
It should be:
FSO.CopyFolder copyfile, desteny, True
Shouldn't be?
Thanks
Beny
If source contains wildcard characters or destination ends with a path
separator (\), it is assumed that destination is an existing folder in which
to copy matching folders and subfolders. Otherwise, destination is assumed
to be the name of a folder to create. In either case, four things can happen
when an individual folder is copied.
a.. If destination does not exist, the source folder and all its contents
gets copied. This is the usual case.
b.. If destination is an existing file, an error occurs.
c.. If destination is a directory, an attempt is made to copy the folder
and all its contents. If a file contained in source already exists in
destination, an error occurs if overwrite is false. Otherwise, it will
attempt to copy the file over the existing file.
d.. If destination is a read-only directory, an error occurs if an attempt
is made to copy an existing read-only file into that directory and overwrite
is false.
An error also occurs if a source using wildcard characters doesn't match any
folders.
The CopyFolder method stops on the first error it encounters. No attempt is
made to roll back any changes made before an error occurs.
You must prevent this situations.... ;)