ZipArchive 的使用
来源:互联网 发布:绵阳自驾租车软件 编辑:程序博客网 时间:2024/05/23 23:09
新建一个项目,首先添加 System.IO.Compression.FileSystem 引用。
解压文件
using System.IO.Compression;namespace cl{ static void Main() { string zipPath = @"c:\example\result.zip"; string extractPath = @"c:\example\extract"; ZipFile.ExtractToDirectory(zipPath, extractPath); }}
压缩单个文件
using System;using System.IO.Compression;namespace cl{ sealed class ZipCreater { static void Main() { using (var zip = ZipFile.Open("ZipCreater.zip", ZipArchiveMode.Create)) { zip.CreateEntryFromFile(@"C:\work\ZipCreater.cs", "ZipCreater.cs"); zip.CreateEntryFromFile("ZipCreater.exe", "ZipCreater.exe"); } } }}
压缩文件夹
using System;using System.IO.Compression;namespace cl{ sealed class Zip { static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: Zip zip-file-name directory-name"); return; } try { ZipFile.CreateFromDirectory(args[1], args[0]); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } } }}
阅读全文
0 0
- ZipArchive 的使用
- zipArchive使用
- ziparchive 使用
- 第三方框架ZipArchive的使用
- iOS 使用ZipArchive压缩文件
- iOS 使用ZipArchive压缩文件
- iOS 使用ZipArchive压缩文件
- 使用ZipArchive压缩文件
- 使用ZipArchive压缩打包想要的文件夹或文件
- php使用ZipArchive函数实现文件的压缩与解压缩
- ZipArchive
- ZipArchive
- ZipArchive
- IOS 使用ZipArchive解压文件
- 使用PHP压缩文件和解压文件 (ZipArchive类的使用)
- 使用PHP的ZipArchive类实现多个文件的zip压缩包打包下载
- php使用 ZipArchive 压缩文件并提供下载
- iOS中使用ZipArchive 压缩和解压缩文件
- Linux学习资源推荐
- 云端的数据安全主要表现在哪些方面
- z-stack中的voidHalLedBlink (uint8 leds, uint8 numBlinks, uint8 percent, uint16 period)函数的深度解析
- 使用attr()设置checked属性时,第二次不起作用
- 约瑟夫循环报数问题
- ZipArchive 的使用
- 使用docker时遇到的问题
- 17.创新与企业家精神——攻其软肋
- 根据经纬度查询相应的省市区名称
- ES报错“Result window is too large”参悟大数据思维
- 《Linux内核设计与实现》读书笔记(五)- 系统调用
- HashMap源码和JDK1.8以后的一些变化
- 开始
- cookie与session详解