mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
IcdZip.Unzip returns a message
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#if SIMPLSHARP
|
using System;
|
||||||
|
#if SIMPLSHARP
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
#else
|
#else
|
||||||
using System;
|
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -17,23 +17,29 @@ namespace ICD.Common.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="outputPath"></param>
|
/// <param name="outputPath"></param>
|
||||||
public static bool Unzip(string path, string outputPath)
|
/// <param name="message"></param>
|
||||||
|
public static bool Unzip(string path, string outputPath, out string message)
|
||||||
{
|
{
|
||||||
|
message = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
#if SIMPLSHARP
|
#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
|
#else
|
||||||
try
|
|
||||||
{
|
|
||||||
using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read))
|
using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read))
|
||||||
archive.ExtractToDirectory(outputPath);
|
archive.ExtractToDirectory(outputPath);
|
||||||
}
|
message = "Success";
|
||||||
catch (Exception)
|
return true;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
message = e.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user