PDA

Click to See Complete Forum and Search --> : Alternative FileCopy


Mark Sreeves
Nov 15th, 1999, 04:05 PM
If you try to use the FileCopy statement on a currently open file, an error occurs.

Does anyone know how I can copy a file which may or may not be open?

This must be possible because you can do it in Windows Explorer

------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

mcleran
Nov 15th, 1999, 09:16 PM
Use the objects provided by the Microsoft Scripting Runtime dll (FileSystemObject & File). Set a reference to Microsoft Scripting Runtime and try something like this:

Dim f as FileSystemObject
Dim fil as File

'instantiate file system object
Set f = New FileSystemObject

'set file reference
Set fil = f.GetFile(path)

'copy the file
fil.Copy(sDestination, Overwrite(True or False))

Mark Sreeves
Nov 15th, 1999, 10:13 PM
OK! OK! you can all stop looking now!
The CopyFile API does the job