private static void OnRenamed(object source, RenamedEventArgs e) { string tempstr; try { // Deleted... FileInfo myOldFileInfo = new FileInfo(e.OldFullPath); string oldName = myOldFileInfo.Name; string oldPath = myOldFileInfo.DirectoryName; FileSystemEventArgs deleted = new FileSystemEventArgs(System.IO.WatcherChangeTypes.Deleted, oldPath, oldName); //OnChanged(source, deleted); XFileAction sourceAction = new XFileAction(e.ChangeType, oldPath, oldName); ChangesQueue.Enqueue(sourceAction); // Created... FileInfo myNewFileInfo = new FileInfo(e.FullPath); string newName = myNewFileInfo.Name; string newPath = myNewFileInfo.DirectoryName; FileSystemEventArgs created = new FileSystemEventArgs(System.IO.WatcherChangeTypes.Created, newPath, newName); XFileAction targetAction = new XFileAction(e.ChangeType, newPath, newName); ChangesQueue.Enqueue(targetAction); //OnChanged(source, created); // Specify what is done when a file is renamed. Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath); tempstr = string.Format("File: {0} renamed to {1}", e.OldFullPath, e.FullPath); myLog.WriteEntry(tempstr); } catch (Exception ex) { tempstr = string.Format("FileSystemWatcher Exception : {0}", ex.Message); myLog.WriteEntry(tempstr); } }
// Define the event handlers. private static void OnChanged(object source, FileSystemEventArgs e) { string tempstr = ""; FileInfo thisEventFile = new FileInfo(e.FullPath); string thisName = thisEventFile.Name; string thisPath = thisEventFile.DirectoryName; XFileAction thisAction = new XFileAction(e.ChangeType, thisPath, thisName); ChangesQueue.Enqueue(thisAction); /*try * { * _pool.WaitOne(); * XFileList.Add(thisAction); * } * catch(Exception ex) * { * tempstr = string.Format("FileSystemWatcher Exception : {0}", ex.Message); * myLog.WriteEntry(tempstr); * } * finally * { * _pool.Release(); * }*/ // Specify what is done when a file is changed, created, or deleted. Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); tempstr = string.Format("Counts=({0},{1}); File: {2} {3}", ChangesQueue.Count, eventOrder.Count, e.FullPath, e.ChangeType); myLog.WriteEntry(tempstr); }
// Define the event handlers. private static void OnChanged(object source, FileSystemEventArgs e) { string tempstr = ""; FileInfo thisEventFile = new FileInfo(e.FullPath); string thisName = thisEventFile.Name; string thisPath = thisEventFile.DirectoryName; XFileAction thisAction = new XFileAction(e.ChangeType, thisPath, thisName); ChangesQueue.Enqueue(thisAction); /*try { _pool.WaitOne(); XFileList.Add(thisAction); } catch(Exception ex) { tempstr = string.Format("FileSystemWatcher Exception : {0}", ex.Message); myLog.WriteEntry(tempstr); } finally { _pool.Release(); }*/ // Specify what is done when a file is changed, created, or deleted. Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); tempstr = string.Format("Counts=({0},{1}); File: {2} {3}", ChangesQueue.Count, eventOrder.Count, e.FullPath, e.ChangeType); myLog.WriteEntry(tempstr); }