When there is a big file moved into the watched folder,it raises created
event even before the file is copied fully.
Copying such files within the created event causes 'file being used by another process' error.
I used a thread that tries to copy the file until it is allowed to do so.but i am still not satisfied.
Can we configure FileSystemWatcher
such that the created event is raised only after the file is fully copied?thanks.
The documentation for the FileSystemWatcher class specifically states your observed behaviour
Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.
You could check that a lock to the file has been released, and then know that the copying is complete?