Re: Permission Denied when using File.Copy or fso.CopyFile
- From: <mpiceni@xxxxxxxxxxxxxxxx>
- Date: Fri, 6 Jul 2007 10:04:39 +0200
If you want something more "elegant", you need to use the CopyEx method of
the CIM_DataFile WMI Class. This method, in case of error during the copy,
returns you a parameter that can be used to retry the copy later, starting
from the exact point where it stopped. Very nice, but, unfortunately, it
cannot overwrite existing files, so you'll need to delete the old files
first, and this is unacceptable if you've a live Web Site. That's why I
didn't propose you that method. Anyway, it exists.
Massimo.
<usenet@xxxxxxxx> ha scritto nel messaggio
news:1183667660.410113.192740@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 4, 3:04 am, <mpic...@xxxxxxxxxxxxxxxx> wrote:
Hi,
If want to do this, you need to enumerate all your files and copy them
one
at a time, otherwise (i.e. if you copy a folder) you cannot say what file
has problems. Moreover, if you check what files are open before starting
your copy, this state may change on the way and the check becomes
unuseful.
Basically, you simply add an On Error Resume Next before starting copy.
Then
check Err.Number after each file copy. If an error occurs, then add your
filename to an array for later retry. Reiterate through the array until
all
files have been copyed (assuming that images are opened for a short time
window while user are browsing).
Hi Massimo,
Thanks for the response. I've set things up this way and so far, it
appears to be working smoothly. When a locked file is encountered, I
stuff the source and destination paths into an array (sourcePath & "|"
& destPath, so I can split on the pipe later). Once the initial run
completes, I return to my array and process those until none are left.
It's not the most elegant solution in the world but it's a nice hack
considering the lack of flock-ish behavior.
Again, my thanks!
.
- References:
- Prev by Date: Re: Connect directly to SQL server to retrieve rows from a Table/View
- Next by Date: count only servers in Active Directory
- Previous by thread: Re: Permission Denied when using File.Copy or fso.CopyFile
- Next by thread: Help needed with my first ever .vbs files.
- Index(es):
Relevant Pages
|