I'm creating a kind of file-editor in WPF, what is the best practice to check if a file has been changed outside of my own WPF application? I know I can track files with the System.IO.FileSystemWatcher
but how can I know if they have been changed outside of my own WPF application?
I would like something as in Notepad++, that gives a kind of warning when a file has been modified outside of Notepad++
Thanks in advance.
FileSystemWatcher
raises events whether the file is modified by your application or whether it is modified by another application.
Listen for file change events provided by FileSystemWatcher
and provide the desired feedback like Notepad++.
Each time before your application changes the file, unlisten to FileSystemWatcher
events, by setting EnableRaisingEvents = false
, change the file, and then set EnableRaisingEvents = true
to listen to events again.