- string zipFilePath = @"d:\test.zip";
- string file1 = @"D:\ 门头照处理 \ 门店照片 2018-3-19 wuxl \ 门店照片 \ 105500035102.jpg";
- string file2 = @"D:\ 门头照处理 \ 门店照片 2018-3-19 wuxl \ 门店照片 \ 105500107146.jpg";
- // 创建并添加被压缩文件
- using (FileStream zipFileToOpen = new FileStream(zipFilePath, FileMode.Create))
- using (ZipArchive archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Create))
- {
- archive.CreateEntryFromFile(file1, "a.jpg");
- archive.CreateEntryFromFile(file2, "b.jpg");
- }
- -
项目要引用 System.IO.Compression,System.IO.Compression.FileSystem
要添加 using System.IO.Compression;
来源: http://www.bubuko.com/infodetail-2560760.html