.NET FileSystemWatcher to detect NTFS security changes

The .NET FileSystemWatcher's Changed event MSDN documentation says:

The Changed event is raised when changes are made to the size, system attributes, last write time, last access time, or security permissions of a file or directory in the directory being monitored.

However, when I try to use this class to capture NTFS security changes to a directory or a file the Changed event never fires.

Is there some way of accomplishing this without polling?

Answers


FileSystemWatcher does watch security permissions changes. You need to include NotifyFilters.Security flag, when you set FileSystemWatcher.NotifyFilter. I tried the code below, changed permissions for a file in Temp folder. The Changed event was triggered.

public static void Main()
{
    var fileSystemWatcher = new FileSystemWatcher("C:\\Temp", "*.*");
    fileSystemWatcher.NotifyFilter = NotifyFilters.Security;
    fileSystemWatcher.Changed += fileSystemWatcher_Changed;
    fileSystemWatcher.EnableRaisingEvents = true;
    Thread.Sleep(-1);
}

private static void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
}

Need Your Help

How to shift subview of UITextView by size of one line when cursor goes to next line?

ios objective-c uitextview

I have a textView and I added an image to this textView. When i write text and go to next line I want to shift this image down by size of one line.. Similar like in twitter app when you create a t...

Can't draw Histogram, 'x' must be numeric

r

I have a data file with this format:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.