C# 解压及压缩文件源码
来源:互联网 发布:李善兰 知乎 编辑:程序博客网 时间:2024/04/30 06:40
using System.IO;using System.Windows.Forms;using ICSharpCode.SharpZipLib.Zip;using ICSharpCode.SharpZipLib.Checksums; public void unZip(string strSouceFile, string strDestFile) { if (!Directory.Exists(strDestFile)) Directory.CreateDirectory(strDestFile); using (ZipInputStream zip = new ZipInputStream(File.OpenRead(strSouceFile))) { ZipEntry theEntry; string fileName; FileStream streamWriter; while ((theEntry = zip.GetNextEntry()) != null) { fileName = Path.GetFileName(theEntry.Name); if (fileName != String.Empty) { streamWriter = new FileStream(strDestFile + fileName, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Write); int size = 2048; byte[] data = new byte[2048]; while (true) { size = zip.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } streamWriter.Close(); } } MessageBox.Show("解压文件成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); } } public void ZipFile(string strSouceFile, string strDestFile) { using (ZipOutputStream stream = new ZipOutputStream(File.Create(strDestFile))) { stream.SetLevel(5); byte[] buffer = new byte[0x1000]; ZipEntry entry = new ZipEntry(Path.GetFileName(strSouceFile)); entry.DateTime = DateTime.Now; stream.PutNextEntry(entry); using (FileStream stream2 = File.OpenRead(strSouceFile)) { int num; do { num = stream2.Read(buffer, 0, buffer.Length); stream.Write(buffer, 0, num); } while (num > 0); MessageBox.Show("压缩文件成功!"); } stream.Finish(); stream.Close(); } }需要引用的dll,下载以下页面的dll
http://download.csdn.net/detail/sky_cat/7236675
0 0
- C# 解压及压缩文件源码
- c# 压缩文件及解压Zip
- c# 压缩文件、压缩多级目录及解压
- C#解压RAR压缩文件
- C#解压RAR压缩文件
- C#压缩文件,解压文件。
- c#解压、压缩文件
- C# 解压RAR压缩文件
- C# 解压zip压缩文件
- C#压缩解压RAR压缩文件
- C#压缩解压RAR压缩文件
- c#解压压缩文件和文件夹
- c#压缩文件,解压文件写法
- C#解压RAR压缩文件(--转载--测试通过)
- C#解压RAR压缩文件[通过软件压包解包]
- C# 解压压缩文件类(ZIP格式)
- VB 利用WINRAR 压缩文件及解压
- VB 利用WINRAR 压缩文件及解压
- Android开发 返回键的复写 onBackPressed()
- 外网访问内网的实现方法
- Python教程学习
- JavaSE_34_成员变量
- LeetCode-Valid Palindrome
- C# 解压及压缩文件源码
- Git学习之一
- Restlet
- B-树和B+树的应用
- tomcat下配置https环境教程
- cocos2d-x 2.2.0 图片选中聚焦 ,图片描边 CCClippingNode 实现
- JavaSE_35_值传递
- 算法思路(续)
- 设计模式一日一练:装饰者模式(Decorator)