How to determine when file copying is ended i'm using c#
edit: we copying files through network from one pc to another one. my task is to watch directory and do some actions after files are copied to it.
How to determine when file copying is ended i'm using c#
edit: we copying files through network from one pc to another one. my task is to watch directory and do some actions after files are copied to it.
Periodically check for size.
Anyway, I recommend you to use CopyFileEx
, that has a progress feature (http://msdn.microsoft.com/en-us/library/aa363852(VS.85).aspx)
If you are using File.Copy()
then this operation is finished after file is actually copied.
I have came across something similar recently. I would use File's open write attribute on the file to see if you can write to the file: e.g. FileStream fs = f.OpenWrite();
if the above statement works then file is not in use i.e. done copying.
Try looking into FileSystemWatcher's Created event.
Some common occurrences, such as copying or moving a file or directory, do not correspond directly to an event, but these occurrences do cause events to be raised. When you copy a file or directory,
the system raises a Created event
in the directory to which the file was copied