C# .NET 使用DotNetZip开源类库 处理 压缩/解压 Zip 处理乱码情况

dotNetZip on CodePlex: http://dotnetzip.codeplex.com/

压缩:

       //1.压缩
            //指定编码,防止中文乱码情况
            using (ZipFile zip = new ZipFile(System.Text.Encoding.UTF8))
            {
                // add this map file into the "images" directory in the zip archive 将该地图文件添加到zip存档中的“images”目录中
                zip.AddFile(@"E:\DemoZip\1.png", "images");
                // add the report into a different directory in the archive 将报告添加到归档中的其他目录中
                zip.AddFile(@"E:\DemoZip\2.txt", "files");
                // 添加到根目录
                zip.AddFile(@"E:\DemoZip\3.txt");
                zip.Save(@"E:\DemoZip\ZipFile.zip");
            }

            //2.解压
            //指定编码,防止存在中文乱码情况
            //如情况:路径中具有非法字符
            using (ZipFile zip = new ZipFile(@"E:\DemoZip\ZipFile.zip", System.Text.Encoding.UTF8))
            {
                zip.ExtractAll(@"E:\DemoZip\ZipFileFolder", ExtractExistingFileAction.OverwriteSilently);
            }
时间: 2024-07-31 13:08:10

C# .NET 使用DotNetZip开源类库 处理 压缩/解压 Zip 处理乱码情况的相关文章

PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载

PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载 http://my.oschina.net/junn/blog/104464 PHP ZipArchive 是PHP自带的扩展类,可以轻松实现ZIP文件的压缩和解压,使用前首先要确保PHP ZIP 扩展已经开启,具体开启方法就不说了,不同的平台开启PHP扩增的方法网上都有,如有疑问欢迎交流.这里整理一下常用的示例供参考. 一.解压缩zip文件 ? 1 2 3 4 5 6 7 8 9 10 11 $zip = new ZipAr

C#压缩解压zip 文件

1 /// <summary> 2 /// Zip 压缩文件 3 /// </summary> 4 public class Zip 5 { 6 public Zip() 7 { 8 9 } 10 #region 加压方法 11 /// <summary> 12 /// 功能:压缩文件(暂时只压缩文件夹下一级目录中的文件,文件夹及其子级被忽略) 13 /// </summary> 14 /// <param name="dirPath&quo

NodeJS 文件(夹)压缩/解压(zip/unzip)

我使用的比较靠谱的,也比较简单,其中archiver很强大,支持zip格式tar格式,只需要提供路径就可以压缩已存在的文件夹. 压缩: 1 var fs = require('fs'); 2 var archiver = require('archiver'); 3 4 var output = fs.createWriteStream('archiver-unzip.zip'); 5 var archive = archiver('zip'); 6 7 archive.on('error',

PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载 &amp;&amp; Linux下的ZipArchive配置开启压缩

PHP ZipArchive 是PHP自带的扩展类,可以轻松实现ZIP文件的压缩和解压,使用前首先要确保PHP ZIP 扩展已经开启,具体开启方法就不说了,不同的平台开启PHP扩增的方法网上都有,如有疑问欢迎交流.这里整理一下常用的示例供参考. 一.解压缩zip文件 ? 1 2 3 4 5 6 7 8 9 10 11 $zip = new ZipArchive;//新建一个ZipArchive的对象 /* 通过ZipArchive的对象处理zip文件 $zip->open这个方法的参数表示处理的

iOS多线程与网络开发之大文件下载 (边下边写/暂停恢复下载/压缩解压zip/多线程下载)

郝萌主倾心贡献,尊重作者的劳动成果,请勿转载. 如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源码下载:点我传送 游戏官方下载:http://dwz.cn/RwTjl 游戏视频预览:http://dwz.cn/RzHHd 游戏开发博客:http://dwz.cn/RzJzI 游戏源码传送:http://dwz.cn/Nret1 A.需求 边下边写入硬盘 显示下载进度 暂停/恢复 下载 解压文件 多线程下载 B.基本知识 1

压缩/解压 zip 时遇到 java.lang.IllegalArgumentException: MALFORMED

错误详情: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "mai

java压缩解压zip文件,中文乱码还需要ant.jar包

va] view plaincopyprint? package cn.cn; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; i

[No0000DF]C# ZipFileHelper ZIP类型操作,压缩解压 ZIP 类封装

using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; using Shared; namespace Helpers { public stat

实现Java代码压缩解压

原因:某个时间想对服务器上的zip中的某些文件进行修改 本来以为很简单的事情,在网上找了好些代码,结果效果都不是很理想. 实现对象:对各种类型的文件夹(包含子文件或子文件夹) 下面介绍一下自己综合网上代码自己写的 首先要倒入一个jar包:(零积分下载) package com.tzx.test2; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import org.ap