解 压缩文件
来源:互联网 发布:破碎人生知乎 编辑:程序博客网 时间:2024/04/29 11:06
使用一个开源的压缩和解压缩库-----SharpZipLib
下载地址:http://www.icsharpcode.net/OpenSource/SharpZipLib/
在这库中,一个压缩文件对应的对象类型为ZipFile,压缩文件由多个压缩条目ZipEntry组成,压缩文件可以看成ZipEntry的集合。
解压缩文件:
压缩文件 :
private void ZipFile()
{
//通过文件流创建对象
System.IO.Stream zipStream = new System.IO.FileStream("demo.zip", System.IO.FileMode.Create);
//通过文件流创建压缩的输出流
ICSharpCode.SharpZipLib.Zip.ZipOutputStream zip =
new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(zipStream);
//压缩执行文件夹下面的图片
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(".");
System.IO.FileInfo[] fis = di.GetFiles("*.jpg");
foreach (System.IO.FileInfo fi in fis)
{
//每一个文件对应一个压缩条目ZipEntry
ICSharpCode.SharpZipLib.Zip.ZipEntry entry =
new ICSharpCode.SharpZipLib.Zip.ZipEntry(fi.Name);
entry.Size = fi.Length;
//加入到压缩流中
zip.PutNextEntry(entry);
//随后加入文件的内容,取得读取文件内容的流
System.IO.Stream input = fi.OpenRead();
Transmite(input, zip);
input.Close();
}
zip.Flush();
zip.Close();
}
- 解 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件
- 压缩文件:
- 压缩文件
- 压缩文件
- Java压缩文件和解压缩文件
- linux下常用压缩文件压包,解包命令
- 写了一个解、压缩文件的shell脚本
- .NET压缩文件
- java 压缩文件
- C#压缩文件
- 软件版本:GA、RC、alpha、beta、gamma等详解
- MyEclipse8.5 安装vss
- (转)修改Ubuntu10.10启动菜单默认系统方法
- ERROR: The import org.apache.commons.logging cannot be resolved
- platform_driver_register() & platform_device_register() 关系
- 解 压缩文件
- 安装制作问题 为什么在做安装程序时提示:msjro.dll受windows系统保护
- Windows群集之NLB
- linux中的libpcap中捕获数据包的时间戳
- thinkvd 视频效果(Thinkvd开发日志)
- 完美的Oracle定时备份
- 软件测试
- 【补足基础】类型转换【转】
- 最近的互联网大会总结