Re: Permission Denied when using File.Copy or fso.CopyFile

Tech-Archive recommends: Fix windows errors by optimizing your registry



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!



.



Relevant Pages

  • Re: A[x][y][z]
    ... This would be a simple one-liner in the elegant Snobol language.Sadly, ... "Let's make our language more like Pascal." ... and array elements. ... whether 'a' is an array of pointers to arrays ...
    (comp.lang.c)
  • Re: A[x][y][z]
    ... > "Let's make our language more like Pascal." ... > and array elements. ... > based on a tiny set of elegant principles. ... > I think the problem is that novices can't ...
    (comp.lang.c)
  • Re: Handling freeform date field order
    ... 'PointedEars' Lahn posted: ... I can't think of an elegant modification to get Y M D order. ... rotate an array in either direction and to transpose a pair (adjacent or ...
    (comp.lang.javascript)
  • Re: Multiple arguments for Hash#delete
    ... Though it doesn't matter as much becuase it's ... Simple and elegant. ... when working on this for Array. ...
    (comp.lang.ruby)
  • Re: ruby1.9 and the retry keyword
    ... clearly isn't a general solution; ... My code walks an array, and may change the current element, which is allowed ... this was the case where i used 'retry' ... an iteration from within), but I can sure live with it. ...
    (comp.lang.ruby)