C# zip/unzip with DotNet framework 4.5
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的更多相关文章
- CentOS安装zip unzip命令
yum install zip unzip
- tar, rar, unrar, zip, unzip
tar 打包/解包/压缩/解压缩文件,注意打包和压缩不是一回事,打包相当于捆绑,压缩是在捆绑好后再把里面的空隙挤出以生成更小的文件 $tar [-zjxcvf] filename.tar[.gz... ...
- Linux zip/unzip命令
From: http://www.ixdba.net/a/os/linux/2010/0725/359.html From: http://www.cnblogs.com/chinareny2k/ar ...
- 压缩 & 解压缩 命令汇总:tar、zip & unzip、
1. tar命令详解 格式:tar [-cxtzjvfpPN] 文件与目录 -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五 ...
- zip / unzip 的用法
zip 1.功能作用:压缩文件或者目录 2.位置:/usr/bin/zip 3.格式用法:zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [z ...
- centos 文档的压缩和打包 gzip,bzip2,xz,zip,unzip,tar,tgz 第九节课
centos 文档的压缩和打包 gzip,bzip2,xz,zip,unzip,tar,tgz 第九节课 SAS盘可以支持热插拔,看机器 tar.zip.tar -czvf 不会动源文件,gz ...
- zip unzip tar 压缩解压
yum install -y unzip zip yum安装zip -r mydata.zip mydata mydata目录压缩为mydata.zipunzip mydata.zip - ...
- linux 安装zip/unzip/g++/gdb/vi/vim等软件
近期公司新配置了一台64位云server.去部署的时候发现,没有安装zip/unzip压缩解压软件. 于是仅仅好自己安装这两个软件.linux最好用的还是yum. 两个指令就安装好了. 首先把软件安装 ...
- Windows Server 2012 上安装 dotNET Framework v3.5
Windows Server 2012不能直接运行dotNET Framework v3.5安装程序进行安装,系统提供通过服务器管理器的添加功能和角色向导进行安装. 安装的前几个步骤再这里略去,在默认 ...
随机推荐
- Spring-boot使用Ehcache配置
1.配置类 @Configuration @EnableCaching public class CacheConfiguration {// implements CachingConfigurer ...
- swift项目中嵌入oc
参考资料 需要注意的是 与oc包含swift不同的是 swift包含oc需要在桥接文件中包含要使用的oc的头文件 demo:swiftPlayOc(提取码:37c6)
- 关于Eclispe插件开发起步(一)
Eclipse中三个最吸引人的地方是: 第一是它创新性的图形API,就是SWT/JFace. 第二是它的插件机制. 第三个是利用它的插件机制开发众多功能强大的插件. 插件成就了Eclipse的今天.E ...
- Android开发了解——Dalvik
Dalvik是Google公司自己设计用于Android平台的Java虚拟机.Dalvik虚拟机是Google等厂商合作开发的Android移动设备平台的核心组成部分之一.它可以支持已转换为 .dex ...
- Airbnb创始人:屌丝的逆袭之路
这位黑发小帅哥名叫Brian Chesky,是Airbnb的联合创始人. 如果在百度一下Airbnb,你就会看到如下事实:Airbnb,即Air Bed and Breakfast,中国名“空中食宿” ...
- Apple Watch: WatchKit 应用程序要点
Apple Watch: WatchKit 应用程序要点 本文译自:Apple Watch: WatchKit App Essentials WatchKit 应用程序架构 上一篇文章简单介绍了 Wa ...
- 对css float 浮动的学习心得
css float浮动详解 @(css float)[hasLayout|clear float|妙瞳] css float的定义和用法 float 属性定义元素在哪个方向浮动.以往这个属性总应用于图 ...
- Android数据存储方式之SharedPreferences
Android平台给我们提供了一个SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数.使用SharedPreferences保存数据,其背后是用xml文件存放数 ...
- MongoDB下载安装
MongoDB官方下载地址:http://www.mongodb.org/ 一.在Windows平台下的安装 1.下载MongoDB数据库 2.设置MongoDB程序存放目录 下载完数据库后,直接解压 ...
- ERwin 连接 mysql
1. install mysql connector; 2. run odbc connection management (c:\windows\syswow64\odbcad32.exe); 3. ...