Monitoring a directory for new file creation without FileSystemWatcher

前端 未结 8 549
臣服心动
臣服心动 2021-01-31 06:51

I have to create a Windows service which monitors a specified folder for new files and processes it and moves it to other location.

I started with using FileSyste

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 07:17

    I would question why not to use the FileSystemWatcher. It registers with the OS and is notified immediately when the event finishes in the file system.

    If you really have to poll, then just create a System.Timers.Timer, create a method for it to call, and check for the file in this method.

提交回复
热议问题