FileSystemWatcher Problem
Hello Everyone and thanks for your helpin advance. I have written an application that is supposed to watch various folders using the FileSystemWatcher. However, I am running into problems with the event handlers not recognizing the event in the folders consistently. Initially, I had a single Windows form that on the for load called various subroutines that in turn invoked their own FileSystemWatcher object for each direcgtory. For Example:
WatchFolder1()
WatchFolder2() .. etc.
However, this seldom picked up any events. I then removed all but one of the subroutine calls which fixed some of the problems, but not all of them. I really can't figure out what the issue is. The folders being watched basically accept only text and PDF files and the type of file does not seem to effect whether the event fires or not. Additionally, I have another Windows form that monitors another folder on the same machine that seems to work perfectly. There seems to be only two differences with the working and non-working application:
1. The working application emails a link to the new or changed file while the non-working one attaches the file to the email. Could this possibly cause a confilct that maybe the event has fired before the save is complete?
2. The working application monitors only one folder. The non-working one montiors more than one. Could this be causing a thrading problem or some other issue?
I am really confused as to what the problem is. Basically, I need to build a solution that monitors multiple folders for changes and then takes the appropriate action depending on the folder and type of activity. Can someone give a few ideas on how to best accomplish this? I know that one solution could be to have one FileSystemWatcher monitor a folder and it's various subfolders, but that would require me to make everything within the same folder which is not optimal for my solution. Also, it would require quite a bit of parsing. Any feedback on this problem and a possible solution would be greatly appreciated. Thanks.
|