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 SendModifyRequest(File file) { Console.WriteLine(FileSystemUtilities.GetTransientFolderPath(file.Path)); NameValueCollection data = new NameValueCollection() { {"name", file.Name}, {"path", FileSystemUtilities.GetTransientFolderPath(file.Path)}, {"expiration_date", file.LastModified.ToString()}, {"identifier", Environment.UserName}, {"file_size", new System.IO.FileInfo(file.Path).Length.ToString()} }; byte[] response = PostDataToServer(data, "modify/"); if (response == null) Console.WriteLine("An Error occured while posting data to server"); else Console.WriteLine("Successfully created file {0} on server", file.Name); }
private void SendOpenRequest(File file) { NameValueCollection data = new NameValueCollection() { {"file_name", file.Name}, {"file_path", FileSystemUtilities.GetTransientFolderPath(file.Path)}, {"date", file.LastModified.ToString()} }; byte[] response = PostDataToServer(data, "open/"); if (response == null) Console.WriteLine("An Error occured while posting Open Event to server"); else Console.WriteLine("Successfully sent open event on {0} to server", file.Name); }
// Special constructor for move, rename events public Event(String fileName, String oldPath, String newPath, FileSystemUtilities.EVENT_ACTIONS action) { File file = new File(fileName, oldPath, newPath); this.File = file; this.Action = action; }