From c793ee83d27cdbe5a5ece68a53cf709051e86f18 Mon Sep 17 00:00:00 2001 From: Nathan Crawford Date: Thu, 18 Feb 2016 18:30:04 -0500 Subject: [PATCH] Check working dir if translations can't be found relative to exe --- embroideryReader/Translation.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/embroideryReader/Translation.cs b/embroideryReader/Translation.cs index 55a17a3..5dcf1f8 100644 --- a/embroideryReader/Translation.cs +++ b/embroideryReader/Translation.cs @@ -122,8 +122,22 @@ namespace embroideryReader private string GetBasePath() { + // Build the path that should be used by default string exePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); - return System.IO.Path.Combine(exePath, TRANSLATIONS_FOLDER); + exePath = System.IO.Path.Combine(exePath, TRANSLATIONS_FOLDER); + + // If the default path exists, use it + if (System.IO.Directory.Exists(exePath)) + { + return exePath; + } + // If the translations folder exists in the current working directory, use it + else if(System.IO.Directory.Exists(TRANSLATIONS_FOLDER)) + { + return TRANSLATIONS_FOLDER; + } + // No usable translations folder found + throw new Exception("Unable to locate a suitable translations directory"); } // Returns the names of available translations