mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-17 13:45:05 +00:00
refactor: IcdZip Unzip raises an exception instead of generating a message
This commit is contained in:
@@ -23,27 +23,16 @@ namespace ICD.Common.Utils.IO.Compression
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="outputPath"></param>
|
/// <param name="outputPath"></param>
|
||||||
/// <param name="message"></param>
|
public static void Unzip(string path, string outputPath)
|
||||||
public static bool Unzip(string path, string outputPath, out string message)
|
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
CrestronZIP.ResultCode result = CrestronZIP.Unzip(path, outputPath);
|
CrestronZIP.ResultCode result = CrestronZIP.Unzip(path, outputPath);
|
||||||
message = result.ToString();
|
if (result != CrestronZIP.ResultCode.ZR_OK)
|
||||||
return result == CrestronZIP.ResultCode.ZR_OK;
|
throw new InvalidOperationException(result.ToString());
|
||||||
#else
|
#else
|
||||||
using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read))
|
using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read))
|
||||||
archive.ExtractToDirectory(outputPath);
|
archive.ExtractToDirectory(outputPath);
|
||||||
message = "Success";
|
|
||||||
return true;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
message = e.Message;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user