Loop until file LastAccessTime is changed
I'm looking for a clever way to implement a while loop in C# that loops continously until FileInfo's LastAccessTime is changed.
I'm using a FileSystemWatcher to raise a change event where I do some wo开发者_StackOverflow中文版rk on the file, but this one fires as soon as I open the file.
Any ideas?
Have a look at the NotifyFilter
property on the FileSystemWatcher
. FileSystemWatcher
does support looking at last access time.
FileSystemWatcher seems like the right way to do this. To only get notifications for LastWrite, set the NotifyFilter
property to reflect that:
watcher.NotifyFilter = NotifyFilters.LastWrite;
精彩评论