[resolved]FileSystemWatcher problem?
I'm using FileSystemWatcher in an application. it monitors the files in a folder, then do some processing. I monitor FileCreate, Change, Rename, Delete event.
the problem is: when I copy some images to that folder, it fired the create event, but the file is not actually ready, so, when I load the file in the event handler, it failed.
how can deal with this correctly?
thanks
bear
Re: FileSystemWatcher problem?
Capture the file name, add it to an array, Thread.Sleep a bit, process it. You could keep it in the array for a while longer if it still fails. You may also want to look at processing those files in separate threads which are invoked from a timer.
Re: [resolved]FileSystemWatcher problem?
thanks for reply.
the problem is because the file size is big, when "created" triggered, the file is not actually ready yet.
refer to http://bloggingabout.net/blogs/jschr.../06/12886.aspx
need make sure the file is ready, then can process more.
thanks again.
bear