public static void EncryptFile(ProgressContext progress, Action<string, ProgressContext> failure) { CreatePassphraseViewController passphraseController = new CreatePassphraseViewController { EncryptedFileName = DateTime.Now.ToString("yyyyMMddHHmmss") }; NSOpenPanel open = new NSOpenPanel { AccessoryView = passphraseController.View, AllowsMultipleSelection = false, CanChooseDirectories = false, CanChooseFiles = true, CanSelectHiddenExtension = true, CollectionBehavior = NSWindowCollectionBehavior.Transient, ExtensionHidden = true, Message = "Please select the file you would like to encrypt", Prompt = "Encrypt file", Title = "Encrypt", TreatsFilePackagesAsDirectories = false, }; open.Begin(result => { if (result == 0 || open.Urls.Length == 0) return; if (!open.Urls[0].IsFileUrl) return; string sourceFilePath = open.Urls[0].Path; open.Close(); IRuntimeFileInfo sourceFile = OS.Current.FileInfo(sourceFilePath); Passphrase passphrase = passphraseController.VerifiedPassphrase; if (passphrase == null) return; IRuntimeFileInfo targetFile = GetTargetFileName(sourceFilePath, passphraseController.EncryptedFileName); ThreadPool.QueueUserWorkItem(delegate { using(new NSAutoreleasePool()) { AxCryptFile.EncryptFileWithBackupAndWipe(sourceFile, targetFile, passphrase.DerivedPassphrase, progress); }; }); }); }