Hi. I am supporting a Windows service that uses FileSystemWatcher to
monitor an inbound directory for new files. If the service is shutdown
and files are dropped to the inbound directory, those files are not
picked up by FileSystemWatcher at service startup.

This is a rare circumstance where the service will be down, but it does
happen occasionally during maintenance windows.

The solution to this problem that is in the code now is that a Timer
has been introduced to watch the directory as well. That forced the
addition of some thread mgmt (lock{}) so that both the timer and the
FileSystemWatcher (on separate threads) don't process the same file.

Is there a way to get FileSystemWatcher to pick files up at startup?
I'd love to bag the Timer (it's always a special feeling ditching
code). :-)

Thanks,
Jeff

Re: FileSystemWatcher on startup? by Michael

Michael
Tue Nov 08 22:16:46 CST 2005


I had the same problem and my solution was to create a separate thread class
that my FSW and timer would feed files to. My class handles all the locking
and tracking of the identified files that need to be processed. If you
want, I can upload the VB 2005 code I use to do this. It's been running
under beta 2 for several months without any crashes or other problems.

Mike Ober.

"Jeff" <jeffrey.jackson@dowjones.com> wrote in message
news:1131490790.773277.49230@g47g2000cwa.googlegroups.com...
> Hi. I am supporting a Windows service that uses FileSystemWatcher to
> monitor an inbound directory for new files. If the service is shutdown
> and files are dropped to the inbound directory, those files are not
> picked up by FileSystemWatcher at service startup.
>
> This is a rare circumstance where the service will be down, but it does
> happen occasionally during maintenance windows.
>
> The solution to this problem that is in the code now is that a Timer
> has been introduced to watch the directory as well. That forced the
> addition of some thread mgmt (lock{}) so that both the timer and the
> FileSystemWatcher (on separate threads) don't process the same file.
>
> Is there a way to get FileSystemWatcher to pick files up at startup?
> I'd love to bag the Timer (it's always a special feeling ditching
> code). :-)
>
> Thanks,
> Jeff
>
>




Re: FileSystemWatcher on startup? by Jeff

Jeff
Wed Nov 09 09:10:14 CST 2005

Thanks for the note (and the offer) Mike. Nah, that's ok. It sounds
like it's about a wash with the solution we have in place (lock{}'ing
the processing method). Not sure it's worth me changing at this point.

Thanks again.
Jeff