If I’m reading a text file in shared access mode and another process truncates it, what is the easiest way to detect that? (I’m excluding the obvious choice of refreshing a FileInfo object periodically to check its size) Is there some convenient way to capture an event? (Filewatcher?)
Share
There is, It’s called FileSystemWatcher.
If you are developing a windows forms application, you can drag-and-drop it from the toolbox.
Here’s some usage example:
It’s in System.IO and System.dll so you should be able to use it in most type of projects.