32 lines
811 B
C#
32 lines
811 B
C#
using System.IO.Compression;
|
|
|
|
namespace ReviewProxy.Lib;
|
|
|
|
public class ZipArchiver : IDisposable
|
|
{
|
|
private FileStream fileStream;
|
|
private ZipArchive archive;
|
|
private DirectoryInfo dirInfo;
|
|
|
|
public ZipArchiver(string outputFilePath, string inputDirectoryPath)
|
|
{
|
|
this.fileStream = new FileStream(outputFilePath, FileMode.CreateNew);
|
|
this.archive = new ZipArchive(this.fileStream, ZipArchiveMode.Create);
|
|
this.dirInfo = new DirectoryInfo(inputDirectoryPath);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
this.archive.Dispose();
|
|
this.fileStream.Dispose();
|
|
}
|
|
|
|
public void Compress()
|
|
{
|
|
foreach (FileInfo file in this.dirInfo.EnumerateFiles())
|
|
{
|
|
this.archive.CreateEntryFromFile(file.FullName, file.Name);
|
|
}
|
|
}
|
|
}
|