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!
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.
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.
精彩评论