From 4af8c816e4c22d84bba6483b21f81416345cc60c Mon Sep 17 00:00:00 2001 From: mightynerd Date: Tue, 6 Jan 2015 15:18:40 +0100 Subject: [PATCH] Added error dialog when directory can't be created #441 --- ShareX.HelpersLib/Helpers/Helpers.cs | 10 +++++++++- ShareX.HelpersLib/Properties/Resources.Designer.cs | 11 ++++++++++- ShareX.HelpersLib/Properties/Resources.resx | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index 29ad0c794..891229b19 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -661,7 +661,15 @@ public static void CreateDirectoryIfNotExist(string path, bool isFilePath = true if (!string.IsNullOrEmpty(path) && !Directory.Exists(path)) { - Directory.CreateDirectory(path); + try + { + Directory.CreateDirectory(path); + } + catch (Exception e) + { + DebugHelper.WriteException(e); + MessageBox.Show(Resources.Helpers_CreateDirectoryIfNotExist_Create_failed_ + "\r\n" + e, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } } diff --git a/ShareX.HelpersLib/Properties/Resources.Designer.cs b/ShareX.HelpersLib/Properties/Resources.Designer.cs index 95ec1c8ca..fe64e244d 100644 --- a/ShareX.HelpersLib/Properties/Resources.Designer.cs +++ b/ShareX.HelpersLib/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -672,6 +672,15 @@ internal static string HashCheckForm_fileCheck_FileCheckCompleted_Start { } } + /// + /// Looks up a localized string similar to Could not create directory, check your path settings:. + /// + internal static string Helpers_CreateDirectoryIfNotExist_Create_failed_ { + get { + return ResourceManager.GetString("Helpers_CreateDirectoryIfNotExist_Create_failed_", resourceCulture); + } + } + /// /// Looks up a localized string similar to Download failed:. /// diff --git a/ShareX.HelpersLib/Properties/Resources.resx b/ShareX.HelpersLib/Properties/Resources.resx index 246140cb2..a0efcfa0b 100644 --- a/ShareX.HelpersLib/Properties/Resources.resx +++ b/ShareX.HelpersLib/Properties/Resources.resx @@ -616,4 +616,7 @@ Would you like to download and install it? Update is available + + Could not create directory, check your path settings: + \ No newline at end of file