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. 三个案例带你看懂LayoutInflater中inflate方法两个参数和三个参数的区别

    关于inflate参数问题,我想很多人多多少少都了解一点,网上也有很多关于这方面介绍的文章,但是枯燥的理论或者翻译让很多小伙伴看完之后还是一脸懵逼,so,我今天想通过三个案例来让小伙伴彻底的搞清楚这个 ...

  2. Android_AsyncTask_json

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...

  3. multithread synchronization use mutex and semaphore

    #include <malloc.h> #include <pthread.h> #include <semaphore.h> struct job { /* Li ...

  4. fstat - 读取文件相关信息

    #fstat读取到的信息 ["dev"]=> int(16777220) ["ino"]=> int(66880002) ["mode&q ...

  5. 报错---[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294**

    原因: 新的SDK不允许在设置rootViewController之前做过于复杂的操作,导致在didFinishLaunchingWithOptions 结束后还没有设置rootViewControl ...

  6. 如何解决linux(ubuntu/CENTOS)中gedit中文乱码的问题

    http://jingyan.baidu.com/article/1709ad80a443c54634c4f09c.html 同时按键盘的Alt 和 F2,就可以打开“运行程序”对话框,这个功能类似于 ...

  7. 【Android自动化打包】03. APK的数字签名

    1. 什么是数字签名?   数字签名就是为你的程序打上一种标记,来作为你自己的标识,当别人看到签名的时候会知道它是与你相关的   2. 为什么要数字签名?    最简单直接的回答: 系统要求的.   ...

  8. webbroswer 后台注入脚本 的方法

    HtmlElement script = webBrowser.Document.CreateElement("script"); script.SetAttribute(&quo ...

  9. GitHub这么火,程序员你不学学吗? 超简单入门教程 干货

    本GitHub教程旨在能够帮助大家快速入门学习使用GitHub. 本文章由做全栈攻城狮-写代码也要读书,爱全栈,更爱生活.原创.如有转载,请注明出处. GitHub是什么? GitHub首先是个分布式 ...

  10. 前端基础系列——CSS规范(文章内容为转载)

    原作者信息 作者:词晖 链接:http://www.zhihu.com/question/19586885/answer/48933504 来源:知乎 著作权归原作者所有,转载请联系原作者获得授权. ...