码迷,mamicode.com
首页 > Windows程序 > 详细

C# .NET 4.5 将多个文件添加到压缩包中

时间:2018-04-13 14:31:29      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:file   nbsp   ring   try   style   项目   bsp   pfile   from   

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;

C# .NET 4.5 将多个文件添加到压缩包中

标签:file   nbsp   ring   try   style   项目   bsp   pfile   from   

原文地址:https://www.cnblogs.com/runliuv/p/8819893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!