c#压缩文件
c# 壓縮文件夾兩種方法:
1.需要引入Ionic.Zip.dll,沒有的安裝nuget包
string toFilePath = "";//生成到哪里 stiring zipFilePath = "";//待壓縮的文件夾var pathList = new List<stirng>(); pathList.add(zipFilePath);//需要壓縮的所有文件夾using(ZipFile zip = new ZipFile(toFilePath, Encoding.Defauft)) {foreach(var path in pathList){string fileName = System.IO.Path.GetFileName(path);string curDir = Directory.GetCurrnetDirectory();Directory.SetCurrentDirectory(toFilePath);zip.addDirectory(path);Directory.SetCurrentDirectory(curDir);}zip.Save(tofilePath + "文件名.zip");return tofilePath + "文件名.zip"; }2. 需要net framework4.5以上版本,簡單易操作
鏈接:https://jingyan.baidu.com/article/3f16e00313a8a72591c10313.html
c#同時壓縮多個文件:c# zip壓縮多個文件_阿道的專欄-CSDN博客
總結
- 上一篇: 收银机和服务器连接不上显示单机,这个收银
- 下一篇: 计算机毕业设计asp.net酒店客房管理