FileSystemWatcher vs polling to watch for file changes

后端 未结 13 2303
一个人的身影
一个人的身影 2020-11-22 05:44

I need to setup an application that watches for files being created in a directory, both locally or on a network drive.

Would the FileSystemWatcher or p

13条回答
  •  渐次进展
    2020-11-22 06:12

    Returning from the event method as quickly as possible, using another thread, solved the problem for me:

    private void Watcher_Created(object sender, FileSystemEventArgs e)
    {
        Task.Run(() => MySubmit(e.FullPath));
    }
    

提交回复
热议问题