void PostEvent (FileAction action, string path, string newPath = null)
{
RenamedEventArgs renamed = null;
if (requestStop || action == 0)
return;
// e.Name
string name = path.Substring (fullPathNoLastSlash.Length + 1);
// only post events that match filter pattern. check both old and new paths for renames
if (!fsw.Pattern.IsMatch (path) && (newPath == null || !fsw.Pattern.IsMatch (newPath)))
return;
if (action == FileAction.RenamedNewName) {
string newName = newPath.Substring (fullPathNoLastSlash.Length + 1);
renamed = new RenamedEventArgs (WatcherChangeTypes.Renamed, fsw.Path, newName, name);
}
fsw.DispatchEvents (action, name, ref renamed);
if (fsw.Waiting) {
lock (fsw) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll (fsw);
}
}
}