Thread: multiple files using filesystemwatcher

  1. #1
    Registered User
    Join Date
    Jul 2010

    multiple files using filesystemwatcher

    Hello guys,
    I need to monitor multiple files in different directories eg C:\logmo C:\mon C:\Program

    The number of directories can be pretty large, can anyone recommend the best approach of doing this? Doing a search on google people suggested making multiple instances of FilesystemWatcher, each with its own filter (ie name) set, but surely this will be very resource intensive?


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > but surely this will be very resource intensive?
    Who knows?

    That really depends on the complexity of your filters, the number of files being watched and the rate of change.

    How long would it take to implement and test a solution?
    If it's only an hour or two, then at least verify that the simple and obvious is far too slow to be of any use.

    That is, before trying to find some strange hack that might take a week to write.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    I would say that is the best solution. Make sure you don't monitor sub-directories if you don't want them and stuff like that.

    Apart from that, you have to think "what else is possible?"

    The only real thing you can do is find a function that monitors less.

    For example FilesystemWatcher specifies that:
    "Setting the Filter property does not decrease what goes into the buffer."
    You can think that FilesystemWatcher calls multiple WinAPI functions to monitor a directory where you would like only one of those functions. Show you would have to use the simpler WinAPI function directly. Of course those are all just assumptions.

    Otherwise you would have to find the implementation of the WinAPI functions and use them to create your own simpler functions, which is not easy at all.

    Another alternative is to "check" instead of "monitor". If your goal is to make a backup every 2 hours maybe it is better to check the files every 2 hours and mark the changes than monitoring them all the time.

    In any case, try it and post your results for future reference

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 08-12-2010, 01:58 PM
  2. Windows shell commands - multiple files
    By Magos in forum Tech Board
    Replies: 3
    Last Post: 02-28-2006, 01:56 AM
  3. Linker errors - Multiple Source files
    By nkhambal in forum C Programming
    Replies: 3
    Last Post: 04-24-2005, 02:41 AM
  4. copy multiple files to a destination file
    By Bones in forum C++ Programming
    Replies: 2
    Last Post: 10-02-2003, 10:47 AM
  5. opening multiple files sequentially
    By moonwalker in forum C Programming
    Replies: 5
    Last Post: 08-20-2002, 09:57 PM