Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring File Changes in C# [duplicate]

Tags:

c#

file

project

I'm using C# for a mini project of mine, I am trying to monitor files that are changed, Deleted, And/or created. And export that to a file. But I am not quite sure how to monitor files. Any ideas?

like image 803
Patrick S Avatar asked May 18 '10 00:05

Patrick S


2 Answers

You can use the FileSystemWatcher class to monitor file creation, modifications, deletions and renames.

You have the following events available:

  • Changed
  • Created
  • Deleted
  • Renamed
like image 63
Christian C. Salvadó Avatar answered Sep 22 '22 11:09

Christian C. Salvadó


you can only monitor one Directory with FSW, if you want more you may have to make multiple instances of FSW. It monitors the directory not the file; if the file is moved (changed+created; changed+renamed) then you need another FSW for that destination folder.

like image 41
Paradigm Avatar answered Sep 23 '22 11:09

Paradigm