views:

90

answers:

2

I made a program which uses a filesystemwatcher component, but it seems to record absolutely EVERY change made, and I want to set it to ignore some file types. How can I set the filter to ignore certain types? For example, .LOG files. I don't want it telling me that that file updates, cause it does it every second practically.

Even better, is there any way to make it ignore some folders?

Thanks for the help!

A: 

MSDN has the details. There is a Filter property on the FileSystemWatcher that you can use to include only those files for which you want notifications.

Dave Swersky
I know, but how do I ignore some file types but include the rest?
Cyclone
+2  A: 

I don't think you can exclude certain file types using only a Filter.

I would suggest that you add a test at the start of each of your handlers to skip any processing of files which you don't want to process.

The FileSystemWatcher watches for changes to all files and folders within a folder, including files and folders within sub-directories. If you want to ignore changes to your log files, for example, it might be a better option to move the log directory to a folder which is not within the path that you are watching.

Dexter
Hmm, could work I guess. Ill try...
Cyclone
Yep, got it. [15 char limit]
Cyclone