public void ExportAccounts() { try { if (AccountViewModels.Any(vm => vm.HasChanges)) { DialogService.Notify("You have unsaved changes. Please save changes before exporting accounts."); return; } using (var dialog = new FolderBrowserDialog()) { if (dialog.ShowDialog() != DialogResult.OK) { return; } var filePath = $@"{dialog.SelectedPath}\exported-accounts-{DateTime.Now.Ticks}.json"; string encrypt(string text) => CryptoService.Encrypt(StorageService.GetSecretKey(Password), text); var data = AccountViewModels.Select(vm => vm.ViewModelToModel(encrypt)); File.WriteAllText(filePath, JsonConvert.SerializeObject(data)); Status = "Accounts exported..."; } } catch (Exception e) { DialogService.Exception(e); } }