FileSystemWatcher Question
-
I admit I haven't done my homework here, but I need to have my application process files after they show up in a directory. The FileSystemWatcher seems like the perfect object to use. When I plug this guy in and add handlers for the FileCreated and FileChanged events, I catch 4 events for every file I copy into my directory; 1 file created and 3 file changed events (this is XP Pro). Is there a simple way to make this object give me 1 notification that a file has been copied and fully written to my directory? I really don't want to have to keep track of waiting for the 4th event. Thanks. Ron
-
I admit I haven't done my homework here, but I need to have my application process files after they show up in a directory. The FileSystemWatcher seems like the perfect object to use. When I plug this guy in and add handlers for the FileCreated and FileChanged events, I catch 4 events for every file I copy into my directory; 1 file created and 3 file changed events (this is XP Pro). Is there a simple way to make this object give me 1 notification that a file has been copied and fully written to my directory? I really don't want to have to keep track of waiting for the 4th event. Thanks. Ron
That's basically the way the underlying Win32 function works. One common approach is to try to open the file - it will be there and accessible when you can open it.