Search code examples
c#filesystemwatcher

Make an event when a file as not arrived after a certain time


I am coding in c# using filesystem watcher to check a directory. How can I say "after 8:00 am if file X is not existing do ....." ?, this have to be verified every day. Thanks for your help !


Solution

  • I don't think you need a FileSystemWatcher here. Simply use a Timer or Scheduled tasks which runs at 8:00, then check for your file exist and get the job done.

    Timer can be used if your application will be running all the time throughout the day 24 x 7, otherise use latter.

    FileSystemWatcher is something, that we use to get notifications about change in the file system anytime and not for checking something exist at particular time.

    Update: You can use the FileSystemWatcher to get the file update immediately, then process it and also the Timer mentioned above which finds whether file hasn't been created till 8.00.