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

最新文章

  1. 【安装MongoDB】CentOS7 下安装NodeJs+Express+MongoDB+Redis
  2. python对XML的解析
  3. TreeMap 的实现
  4. JMeter中的关联-正则表达式提取(1)
  5. http 响应码
  6. jsp中将后台传递过来的json格式的list数据绑定到下拉菜单select
  7. C++ Preprosessor import
  8. oracle系列--解锁数据库
  9. [刷题]Codeforces 746G - New Roads
  10. fiddler安装及配置+利用fiddler进行简单抓包(wawayaya阅读)
  11. C#中DataTable与XML格式的相互转换
  12. 1.3 第一个python程序
  13. 【Java】浅谈Java IO
  14. c#如何判断字符串是否含中文
  15. 积跬步,聚小流-------js实现placeholder的效果
  16. CCPC-Wannafly Winter Camp Day7 (Div2, onsite)
  17. wifi钓鱼 强势拿你的wifi密码
  18. jquery加载解析XML文件
  19. 【spring cloud】spring cloud分布式服务eureka启动时报错:java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
  20. 【占位】HihoCoder 1160 : 攻城略地(并查集好题)

热门文章

  1. Docker学习总结(13)——从零开始搭建Jenkins+Docker自动化集成环境
  2. bzoj3626【LNOI2014】LCA
  3. mybatis和hibernate的区别【转】
  4. hdoj 1013Digital Roots
  5. linux定时备份mysql数据库文件
  6. STL 之 iterator traits 备忘
  7. hdu-3401-Trade-单调队列优化的DP
  8. Python爬糗百热门20条并邮件分发+wxPython简易GUI+py2app转成可运行文件
  9. [Android] Android开发优化之——对界面UI的优化(2)
  10. 子文件夹的遍历(python、matlab)