From 86dcd8d7770aad8d862092591d50849d6bb17e10 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Fri, 20 Jul 2018 10:27:27 +0200 Subject: [PATCH] Catch permission exception on folder selection If users don't have the permissions to scan a folder hierarchy, they're not supposed to transfer it anyway - so just show an error message. Fixes #48 --- ATxTray/AutoTxTray.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ATxTray/AutoTxTray.cs b/ATxTray/AutoTxTray.cs index fa30f2e..9759849 100644 --- a/ATxTray/AutoTxTray.cs +++ b/ATxTray/AutoTxTray.cs @@ -303,7 +303,17 @@ namespace ATxTray return; } - NewTxConfirmationDialog(); + try { + NewTxConfirmationDialog(); + } + catch (UnauthorizedAccessException ex) { + MessageBox.Show("ERROR: the selected directory\n\n" + + $"[{_selectedDir.Name}]\n\n" + + "contains files or folders that are not readable\n" + + "due to insufficient permissions!\n\n" + + ex.Message, + "Error reading directory", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } /// <summary> -- GitLab