Get detailed information on FileSystemEventArgs.ChangeType
I using the FileWatcher Class to locate changes on Files in a specific Folder.
I m开发者_如何学JAVAanaged to detect Changes on Files but not detailed Information.
On the WatcherChangeTypes Enumeration Page
http://msdn.microsoft.com/en-us/library/t6xf43e0%28v=VS.100%29.aspx
they write the Change Type detects the changes include: changes to size, attributes, security settings, last write, and last access time.
Is there a way to detect which kind of change happened?
Thats the Event handler method i use.
private void OnChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("File: " + e.FullPath + " Change Type: " + e.ChangeType);
}
Thank you in advance
Case
I think what you want is a FileSystemWatcher
with a NotifyFilter
tuned to a specific type of change(s):
var fsw = new FileSystemWatcher("C:\\");
fsw.NotifyFilter = NotifyFilters.LastAccess;
fsw.Changed += OnFileAccessed
private static void OnFileAccessed( object sender, FileSystemEventArgs e )
{
...
}
If you wanted different events to fire based on different change triggers, I believe you would need multiple watchers on the same file.
See FileSystemWatcher.NotifyFilter for more.
精彩评论