using System;
using System.IO;
using System.IO.Compression;
namespace Vinno.FIS.Sonopost.Helpers
{
public class CompressHelper
{
///
/// 压缩文件
///
/// Source folder path
/// sava file path
public static void CompressFolder(string sourceFolderPath, string saveFilePath)
{
FileHelper.DeleteFile(saveFilePath);
var directoryPath = Path.GetDirectoryName(saveFilePath);
DirectoryHelper.CreateDirectory(directoryPath);
ZipFile.CreateFromDirectory(sourceFolderPath, saveFilePath);
}
///
/// 解压缩文件
///
/// decompress source path.
/// destinion path
public static void DeCompressAll(string sourcePath, string destinionPath)
{
if (!File.Exists(sourcePath))
{
throw new ArgumentException($"Can't find decompress source path {sourcePath}");
}
DirectoryHelper.DeleteDirectory(destinionPath);
ZipFile.ExtractToDirectory(sourcePath, destinionPath);
}
}
}