Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO.Compression;
- public bool QuickZip(string[] filesToZip, string destinationZipFullPath)
- {
- try
- {
- // Delete existing zip file if exists
- if (File.Exists(destinationZipFullPath))
- File.Delete(destinationZipFullPath);
- using (ZipArchive zip = ZipFile.Open(destinationZipFullPath, ZipArchiveMode.Create))
- {
- foreach (var file in filesToZip)
- {
- zip.CreateEntryFromFile(file, Path.GetFileName(file), CompressionLevel.Optimal);
- }
- }
- return File.Exists(destinationZipFullPath);
- }
- catch (Exception e)
- {
- Console.WriteLine($"Exception: {e.Message}");
- return false;
- }
- }
Add Comment
Please, Sign In to add comment