ZipHelper.cs 711 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.IO.Compression;
  5. using System.Text;
  6. namespace Bowin.Common.Utility
  7. {
  8. public class ZipHelper
  9. {
  10. public static void SaveZipFile(List<ZipFile> fileList, Stream stream)
  11. {
  12. using (var zipArchive = new ZipArchive(stream, ZipArchiveMode.Create))
  13. {
  14. fileList.ForEach(file =>
  15. {
  16. var zipArchiveEntry = zipArchive.CreateEntryFromFile(file.FilePath, file.FileName);
  17. });
  18. }
  19. }
  20. }
  21. public class ZipFile
  22. {
  23. public string FilePath { get; set; }
  24. public string FileName { get; set; }
  25. }
  26. }