C#中我们使用比较多的文件压缩第三方DLL就是Ionic.Utils.Zip.dll。但是这个DLL只支持对现有文件进行压缩,而不支持内存压缩,如果需要使用内存压缩,那么有第三方DLL ICSharpCode.SharpZipLib.dll。下面把例子粘出来:using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;namespace ConsoleApplica...
Atitit. 解压缩zip文件 的实现最佳实践 java c# .net php 1. Jdk zip 跟apache ant zip 1 2. Apache Ant包进行ZIP文件压缩,upzip 大概流程.. 1 3. 读文件名称ok,但是cant读取到input说NPE.. 2 4. Ant1.8.2.jar 2 5. #---详细code 2 6. 参考 4 1. Jdk zip 跟apache ant zip 下面实现的功能是zip文件中的图像文件解压到当前目录下,用jdk自带的处理zip文件的代码处理的,但是不能处理中文名称的文件,要不...
SharpZipLib: recursively zip/unzip directory structure 001 // Project: Salient 002 // http://salient.codeplex.com 003 // 004 // Copyright 2010, Sky Sanders <sky at skysanders.net> 005 // Dual licensed under the MIT or GPL Version 2 licenses. 006 // http://salient.codeplex.com/license 007 //? 008 // Date: May 24 2010 009 ? 010 #region 011 ? 012 using System; 013 using System.Collectio...
如何将多个文件(在服务器中)压缩到一个存档中?解决方法:以下代码使用了我们的Rebex ZIP,并显示了如何在不使用任何临时文件的情况下将文件添加到ZIP存档中.然后将ZIP发送到Web浏览器.// prepare MemoryStream to create ZIP archive within
using (MemoryStream ms = new MemoryStream())
{// create new ZIP archive within prepared MemoryStreamusing (ZipArchive zip = new ZipArchive(ms)){ // add some files to ...
我想从一个zip文件中读取一个二进制文件而不将其解压缩.
压缩文件结构:zipFolderName/subFolder/BinFile在BinFile中,我有:Id1, id2, value1 // id1, id2 are string, value1 is int在C#中:ZipEntry binFileName = …; // it has been got from zipFile entriesMemoryStream ms = new MemoryStream();binFileName.Extract(ms);using (BinaryReader reader = new BinaryReader(ms))
{string id1 = reader.ReadString(); // error...
我有一个视图,它返回一个包含多个页面的pdf(使用iTextSharp),但现在我必须更改它,以便每个页面都是一个单独的pdf(带有它自己的唯一标题)并返回一个zip文件.
我的原始代码如下所示:public FileStreamResult DownloadPDF()
{MemoryStream workStream = new MemoryStream();Document document = new Document();PdfWriter.GetInstance(document, workStream).CloseStream = false;document.Open();// Populate pdf itemsdocument.Clo...
DotNetZip on CodePlex: http://dotnetzip.codeplex.com/
详细的可以看源代码……总之感觉比SharpZipLib好用。而且DotNetZip支持VB,C#以及任何.NET语言。
加压:(从CodePlex上偷过来的) using (ZipFile zip = new ZipFile()){// add this map file into the "images" directory in the zip archive 把这个PNG文件添加到zip档案的"images"目录下zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");// add the repor...
我希望能够像读取物理文件夹中的文件一样读取zip文件中的文件.如何在不提取文件的情况下执行此操作?解决方法:有一些组件允许您从.NET应用程序中查看.zip文件的内容:
> http://www.icsharpcode.net/opensource/sharpziplib/ – (免费开源)> http://xceed.com/Zip_Net_Intro.html – (商业)
我之前使用过#ziplib,但它的工作原理并不是很广泛.
我试图检查zip文件中是否存在文件夹.代码如下://All entries refered too exists.
//For files (Workes fine, returns true)
var hello1 = zip.Any(entry => entry.FileName.Equals(@"Patients.xml"));
var hello2 = zip.Any(entry => entry.FileName.Equals(@"Bookings.xml"));//For folders (Dosent work (returns false))
var result1 = zip.Any(entry => entry.FileName.Equals(@"PatientsF"));
var result2 = zip.Any(entry ...
首先,我想说我已经尝试寻找解决方案,我没有找到一个我不必解压缩,添加我的文件夹,然后再拉链.我没有使用任何第三方库.如果可能的话,我想使用system.io.compression来做这个…如果不是,我会使用dotnetzip作为我的最后手段.
TL;博士.我希望能够将包含文件的目录添加到已创建的zip文件中.这可以使用system.io.compression库吗?
编辑:using (FileStream zipToOpen = new FileStream(zipfile, FileMode.Open)){using (ZipArchive arch...
我试图在内存中创建一个SQLite数据库,然后将其直接添加到我创建的zip文件中.到目前为止,我可以使用ZipArchive和ZipFile类创建zip文件.但是,我找不到将在内存中创建的SQLite数据库添加到zip容器的方法.
以下是我必须在内存中创建数据库的代码:private static void MemoryDB(){SQLiteConnection conn = new SQLiteConnection("Data Source = :memory:");conn.Open();String sql = "CREATE TABLE highscores (name VARCHAR(25), scor...
我有一个包含文件夹层次结构和文件的zip文件.\images\images\1.jpg
\images\2.jpg
\something\something\a.exe
\something\something\b.exe
1.txt我需要将此zip文件的内容解压缩到一个位置.我还需要保留zip文件的结构.
我读过.NET的GZipStream和DeflateStream,但我认为它太复杂了“.
我过去也曾将DotNetZip和SharpZipLib用于个人项目,但由于这是与工作相关的,而且我在一家大公司工作,我很难说服合法使用这些库.
题:是否可以使用.N...