From 56a3068ec9e440f790d47d8d878808455f0944f8 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 19 Oct 2014 11:48:10 +0300 Subject: [PATCH] fixed #343: Actions output can end with text instead only extension --- HelpersLib/Extensions/EnumExtensions.cs | 2 +- HelpersLib/ExternalProgram.cs | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/HelpersLib/Extensions/EnumExtensions.cs b/HelpersLib/Extensions/EnumExtensions.cs index 1404c936e..93f035b28 100644 --- a/HelpersLib/Extensions/EnumExtensions.cs +++ b/HelpersLib/Extensions/EnumExtensions.cs @@ -53,7 +53,7 @@ public static string GetDescription(this Enum value) public static string GetLocalizedDescription(this Enum value, ResourceManager resourceManager) { - string resourceName = value.GetType() + "_" + value; + string resourceName = value.GetType().Name + "_" + value; string description = resourceManager.GetString(resourceName); if (string.IsNullOrEmpty(description)) diff --git a/HelpersLib/ExternalProgram.cs b/HelpersLib/ExternalProgram.cs index e08e4d95c..244e0897a 100644 --- a/HelpersLib/ExternalProgram.cs +++ b/HelpersLib/ExternalProgram.cs @@ -68,13 +68,15 @@ public string Run(string filePath) try { + string newFilePath = ""; + using (Process process = new Process()) { ProcessStartInfo psi = new ProcessStartInfo(Path); if (string.IsNullOrEmpty(Args)) { - psi.Arguments = filePath; + psi.Arguments = '"' + filePath + '"'; } else { @@ -82,8 +84,15 @@ public string Run(string filePath) if (!string.IsNullOrEmpty(OutputExtension)) { - filePath = Helpers.ChangeFilenameExtension(filePath, OutputExtension); - args = args.Replace("%output", '"' + filePath + '"'); + newFilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath)); + + if (!OutputExtension.Contains(".")) + { + OutputExtension = "." + OutputExtension; + } + + newFilePath += OutputExtension; + args = args.Replace("%output", '"' + newFilePath + '"'); } psi.Arguments = args; @@ -97,6 +106,11 @@ public string Run(string filePath) process.WaitForExit(); } + if (!string.IsNullOrEmpty(newFilePath) && File.Exists(newFilePath)) + { + return newFilePath; + } + return filePath; } catch (Exception e)