Home All Groups Group Topic Archive Search About

File finshed being copied

Author
24 Jan 2006 4:41 PM
Craig HB
I want to copy a file from a Source location to a Destination location, but
the file is sometimes in the process of being copied to that Source location.

How can I check that the file has been copied to the Source location and is
ready to be copied to the Destination location, without me getting a "being
used by another process" exception.

Thanks, Craig

Author
24 Jan 2006 5:12 PM
Vadym Stetsyak
AFAIK there is no good way how you can detect if file is fully copied or
still being copied.

For e.g. application can open file for exclusive use, then all others will
not receive access to the file.

If the code that copies source file is your own, you can create mutex ( for
interprocess ) or event ( for inprocess)
synchronization. That is if copying is finished event is signaled, and you
can start copying file to other location.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Show quote
"Craig HB" <Crai***@discussions.microsoft.com> wrote in message
news:42E5F83C-8A3F-43CF-9B82-E1B3BAD0C8E6@microsoft.com...
>I want to copy a file from a Source location to a Destination location, but
> the file is sometimes in the process of being copied to that Source
> location.
>
> How can I check that the file has been copied to the Source location and
> is
> ready to be copied to the Destination location, without me getting a
> "being
> used by another process" exception.
>
> Thanks, Craig
Author
24 Jan 2006 7:35 PM
Michael D. Ober
I always put my file copies in a Try...Catch... handler for this very
reason.  Sometimes I ignore the error and other times I wait for a few
seconds and try again.

Mike Ober.

Show quote
"Craig HB" <Crai***@discussions.microsoft.com> wrote in message
news:42E5F83C-8A3F-43CF-9B82-E1B3BAD0C8E6@microsoft.com...
> I want to copy a file from a Source location to a Destination location,
but
> the file is sometimes in the process of being copied to that Source
location.
>
> How can I check that the file has been copied to the Source location and
is
> ready to be copied to the Destination location, without me getting a
"being
> used by another process" exception.
>
> Thanks, Craig
Author
25 Jan 2006 4:19 PM
Dinesh
As implied by Vadym and Mike - CreateFile (or any of your variants) in
exclusive mode should serve the purpose.

Dinesh Sinha
<http://www.geocities.com/dinesh_sinha>

AddThis Social Bookmark Button