add reference System.IO.Compression.FileSystem

    public class ZipHelper
{
public static string UnZip(string inputFile)
{
string outDir = System.Environment.CurrentDirectory + "\\executor\\";
if (UnZip(inputFile, outDir))
return outDir;
else
return "";
} public static bool UnZip(string inputFile, string outputDir)
{
bool result = false;
try
{
//ZipFile.ExtractToDirectory(inputFile, outputDir);
using (ZipInputStream s = new ZipInputStream(File.OpenRead(inputFile)))
{ ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{ Console.WriteLine(theEntry.Name); string directoryName = Path.GetDirectoryName(theEntry.Name);
//string directoryName = outputDir;
string fileName = Path.GetFileName(theEntry.Name); // create directory
if (directoryName.Length > )
{
Directory.CreateDirectory(directoryName);
} if (fileName != String.Empty)
{
using (FileStream streamWriter = File.Create(theEntry.Name))
{ int size = ;
byte[] data = new byte[];
while (true)
{
size = s.Read(data, , data.Length);
if (size > )
{
streamWriter.Write(data, , size);
streamWriter.Close();
}
else
{
break;
}
}
}
}
}
} result = true;
}
catch
{
}
return result;
} //public static bool UnZip(string inputFile, string outputDir)
//{
// bool result = false;
// try
// {
// ZipFile.ExtractToDirectory(inputFile, outputDir);
// result = true;
// }
// catch
// {
// }
// return result;
//}
}

C# zip/unzip with DotNet framework 4.5的更多相关文章

  1. CentOS安装zip unzip命令

    yum install zip unzip

  2. tar, rar, unrar, zip, unzip

    tar 打包/解包/压缩/解压缩文件,注意打包和压缩不是一回事,打包相当于捆绑,压缩是在捆绑好后再把里面的空隙挤出以生成更小的文件 $tar [-zjxcvf] filename.tar[.gz... ...

  3. Linux zip/unzip命令

    From: http://www.ixdba.net/a/os/linux/2010/0725/359.html From: http://www.cnblogs.com/chinareny2k/ar ...

  4. 压缩 & 解压缩 命令汇总:tar、zip & unzip、

    1. tar命令详解     格式:tar [-cxtzjvfpPN] 文件与目录 -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五 ...

  5. zip / unzip 的用法

    zip 1.功能作用:压缩文件或者目录 2.位置:/usr/bin/zip 3.格式用法:zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [z ...

  6. centos 文档的压缩和打包 gzip,bzip2,xz,zip,unzip,tar,tgz 第九节课

    centos  文档的压缩和打包   gzip,bzip2,xz,zip,unzip,tar,tgz  第九节课 SAS盘可以支持热插拔,看机器 tar.zip.tar -czvf 不会动源文件,gz ...

  7. zip unzip tar 压缩解压

    yum install -y unzip zip    yum安装zip -r mydata.zip mydata    mydata目录压缩为mydata.zipunzip mydata.zip - ...

  8. linux 安装zip/unzip/g++/gdb/vi/vim等软件

    近期公司新配置了一台64位云server.去部署的时候发现,没有安装zip/unzip压缩解压软件. 于是仅仅好自己安装这两个软件.linux最好用的还是yum. 两个指令就安装好了. 首先把软件安装 ...

  9. Windows Server 2012 上安装 dotNET Framework v3.5

    Windows Server 2012不能直接运行dotNET Framework v3.5安装程序进行安装,系统提供通过服务器管理器的添加功能和角色向导进行安装. 安装的前几个步骤再这里略去,在默认 ...

随机推荐

  1. JS 笔记

    如何定义一个函数呢?基本语法如下: function 函数名() {      函数代码; } 说明: 1. function定义函数的关键字. 2. "函数名"你为函数取的名字. ...

  2. 修改UILabel的行间距

    在iOS开发中  有时候为了调整一些UI效果  我们需要调整UILabel之间的行间距: contentLabel.text:label上显示的文字内容; 5:label行间距; contentLab ...

  3. Number of failed login attempts exceeds threshold value

    OEM发出好多告警,Number of failed login attempts exceeds threshold value. profile当前配置10次失败就会锁定user 查看下,dba_ ...

  4. java常用linux命令

    1.ifconfig查看ip 2.查询 例如:find / -name httpd.conf 3.查看是否有tomcat进程 ps –ef|grep tomcat 来查看是否有tomcat进程 4.杀 ...

  5. uva - 133 The Dole Queue(成环状态下的循环走步方法)

    类型:循环走步 #include <iostream> #include <sstream> #include <cstdio> #include <cstr ...

  6. dig命令浅析

    dig命令,功能更强大的命令. man dig dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-m] \ [-p ...

  7. confirm的用法

    内容换行:第一种方法:var str = "aaaaa\\n11111";confirm(str.replace("\\n","\n")); ...

  8. 使用WCF和WEBService出现配置的问题

    错误代码:system.serviceModel/bindings/customBinding 处的绑定没有名称为"SMSServiceServiceSoapBinding"的已配 ...

  9. SQLServer数据操作(建库、建表以及数据的增删查改)

              SQLSever数据操作   一.建立数据库:   create database DB ---数据库名称 (          name=data1 --文件名,         ...

  10. asp.net 后台弹出提示框

    1.后台弹出提示信息方法 Response.Write("<scripttype="text/javascript">alert('你所查询的数据不存在!') ...