private void OnRenamed(object source, RenamedEventArgs e) { // Specify what is done when a file is renamed. mainForm.addFileChange("File: " + e.OldFullPath + " renamed to " + e.FullPath); FileEvent fe = new FileEvent(++eventnum, e.ChangeType, e.FullPath, e.OldFullPath); proc.addevent(ref fe); }
public void addevent(ref FileEvent fe) { lock (eventTable) { eventTable.Add(fe.eventnum, fe); } }
public void enqueueEvent(ref FileEvent fe) { lock (eventQueue) { eventQueue.Enqueue(fe); } cond.Set(); }
private void OnCreated(object source, FileSystemEventArgs e) { mainForm.addFileChange("File: " + e.FullPath + " " + e.ChangeType); FileAttributes fa = File.GetAttributes(e.FullPath); if (fa == FileAttributes.Directory) { /*文件夹新建时,所有子文件也要生成*/ recurAddevent(e.FullPath, e.ChangeType); } FileEvent fe = new FileEvent(++eventnum, e.ChangeType, e.FullPath); proc.addevent(ref fe); }
private void recurAddevent(string dir, WatcherChangeTypes changetype) { string[] filelist = Directory.GetFileSystemEntries(dir); foreach (string file in filelist) { if (Directory.Exists(file)) { recurAddevent(file, changetype); } else { FileEvent fe = new FileEvent(++eventnum, changetype, file); proc.addevent(ref fe); } } }