From ec4abcadd05143e3bc429c457e74f83261fb761a Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 17 Oct 2017 11:47:58 -0400 Subject: [PATCH] IcdZip.Unzip returns a message --- ICD.Common.Utils/IcdZip.cs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/ICD.Common.Utils/IcdZip.cs b/ICD.Common.Utils/IcdZip.cs index fce6fb7..880bd85 100644 --- a/ICD.Common.Utils/IcdZip.cs +++ b/ICD.Common.Utils/IcdZip.cs @@ -1,7 +1,7 @@ -#if SIMPLSHARP +using System; +#if SIMPLSHARP using Crestron.SimplSharp; #else -using System; using System.IO.Compression; #endif @@ -17,23 +17,29 @@ namespace ICD.Common.Utils /// /// /// - public static bool Unzip(string path, string outputPath) + /// + public static bool Unzip(string path, string outputPath, out string message) { + message = null; + + try + { #if SIMPLSHARP - return CrestronZIP.Unzip(path, outputPath) == CrestronZIP.ResultCode.ZR_OK; + CrestronZIP.ResultCode result = CrestronZIP.Unzip(path, outputPath); + message = result.ToString(); + return result == CrestronZIP.ResultCode.ZR_OK; #else - try - { using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read)) archive.ExtractToDirectory(outputPath); - } - catch (Exception) - { - return false; - } - - return true; + message = "Success"; + return true; #endif + } + catch (Exception e) + { + message = e.Message; + return false; + } } } }