private void OnDeleted(object source, FileSystemEventArgs e) { if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath) || FileSystemUtilities.isTemporaryFile(e.FullPath)) { return; } String fileName = FileSystemUtilities.ExtractNameFromPath(e.Name); // This is done to account for move events nameOfDeletedFile = fileName; pathOfDeletedFile = e.FullPath; }
private void OnCreated(object source, FileSystemEventArgs e) { if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath)) { return; } Console.WriteLine("You moved {0} and the deleted file last was {1}", e.Name, nameOfDeletedFile); String fileName = FileSystemUtilities.ExtractNameFromPath(e.Name); if (fileName.Equals(nameOfDeletedFile)) { Console.WriteLine("You moved {0}", e.Name); events.Enqueue(new Event(fileName, pathOfDeletedFile, e.FullPath, FileSystemUtilities.EVENT_ACTIONS.move)); } }
private bool SendRenameRequest(File file) { // Send the old path and the new path, that's it ;) NameValueCollection data = new NameValueCollection() { { "old_path", FileSystemUtilities.GetTransientFolderPath(file.Path) }, { "new_path", FileSystemUtilities.GetTransientFolderPath(file.NewPath) }, { "old_name", FileSystemUtilities.ExtractNameFromPath(file.Path) }, { "new_name", file.Name } }; byte[] response = PostDataToServer(data, "rename/"); if (response == null) { return(false); } else { String responseString = System.Text.Encoding.Default.GetString(response); return(responseString.Equals("Exists") ? true : false); } }
private void OnRenamed(object source, RenamedEventArgs e) { if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath)) { return; } // If any temp file was renamed, send a modify event String oldFileName = FileSystemUtilities.ExtractNameFromPath(e.OldName); Console.WriteLine(oldFileName); if (FileSystemUtilities.isTemporaryFile(oldFileName)) { events.Enqueue(new Event(FileSystemUtilities.ExtractNameFromPath(e.Name), e.FullPath, FileSystemUtilities.EVENT_ACTIONS.modify)); return; } // Otherwise, it is a normal rename event so send a put request if (FileSystemUtilities.fileIsImportant(e.FullPath)) { Console.WriteLine(FileSystemUtilities.ExtractNameFromPath(e.FullPath) + "|" + e.FullPath); events.Enqueue(new Event(FileSystemUtilities.ExtractNameFromPath(e.FullPath), e.OldFullPath, e.FullPath, FileSystemUtilities.EVENT_ACTIONS.rename)); } }