Questions tagged [dotnetzip]

Questions dealing with the DotNetZip open-source zip library for .NET

DotNetZip is an open source zip library. DotNetZip works on PCs with the full .NET Framework, and also runs on mobile devices that use the .NET Compact Framework. Silverlight is also supported.

Below is an example of using the library with C#:

 using (ZipFile zip = new ZipFile())
 {
     // add this map file into the "images" directory in the zip archive
     zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
     // add the report into a different directory in the archive
     zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
     zip.AddFile("ReadMe.txt");
     zip.Save("MyZipFile.zip");
 }

Note: Just for reference the project builds into Ionic.Zip.dll

Installation

DotNetZip can most easily be installed through its NuGet package.

Install-Package DotNetZip
460 questions
50
votes
8 answers

Creating Zip file from stream and downloading it

I have a DataTable that i want to convert it to xml and then zip it, using DotNetZip. finally user can download it via Asp.Net webpage. My code in below dt.TableName = "Declaration"; MemoryStream stream = new MemoryStream(); …
Navid Farhadi
  • 3,397
  • 2
  • 28
  • 34
36
votes
4 answers

DotNetZip add files without creating folders

using (ZipFile zip = new ZipFile()) { foreach(string file in Directory.GetFiles(folder)) { zip.AddFile(file, Path.GetFileName(file)); } zip.Save("test.zip")); } Each time I add a file, it's creating a new subfolder for…
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
36
votes
3 answers

Extract a ZIP file programmatically by DotNetZip library?

I have a function that get a ZIP file and extract it to a directory (I use DotNetZip library.) public void ExtractFileToDirectory(string zipFileName, string outputDirectory) { ZipFile zip = ZipFile.Read(zipFileName); …
Ehsan
  • 3,431
  • 8
  • 50
  • 70
35
votes
3 answers

The same volume can not be used as both the source and destination

I'm creating split archives using the following code: string filename = "FileName.pdf"; using (ZipFile zip = new ZipFile()) { zip.UseZip64WhenSaving = Zip64Option.Default; zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default; using…
jmc
  • 1,649
  • 6
  • 26
  • 47
29
votes
5 answers

create zip file in .net with password

I'm working on a project that I need to create zip with password protected from file content in c#. Before I've use System.IO.Compression.GZipStream for creating gzip content. Does .net have any functionality for create zip or rar password protected…
Reza Akraminejad
  • 1,412
  • 3
  • 24
  • 38
27
votes
1 answer

Set password on Zip file using DotNetZip

I'm using DotNetZip to zip my files, but I need to set a password in zip. I tryed: public void Zip(string path, string outputPath) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(path); …
Jean Carlos
  • 1,613
  • 3
  • 18
  • 26
25
votes
1 answer

Using a MemoryStream with FileStreamResult possible?

I'm using DotNetZip to create a zip file and pass it to a FileResult. On debug, I can verify that the MemoryStream contains a file, but when I run it through FileStreamResult, it returns 0bytes: public FileResult GetZipFiles(int documentId) { …
chum of chance
  • 6,200
  • 10
  • 46
  • 74
24
votes
2 answers

DotNetZip - rename file entry in zip file while compressing

Using DotNetZip, is it possible to compress a file such that the zip lists a different file name for a file than the file name on disk? For example, I want to add myFile.txt to a zip file, but I want it to be called otherFile.txt.
Suraj
  • 35,905
  • 47
  • 139
  • 250
21
votes
3 answers

DotNetZip BadReadException on .Extract

I've got a weird file that when zipped with DotNetZip creates an 'ununzipable' archive. When I try to unzip it with 7zip it fails with CRC failed in 'AjaxControlToolkit.dll'. File is broken. When I zip it with 7zip manually it unzips fine. Has…
Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70
18
votes
5 answers

Add Files Into Existing Zip - performance issue

I have a WCF webservice that saves files to a folder(about 200,000 small files). After that, I need to move them to another server. The solution I've found was to zip them then move them. When I adopted this solution, I've made the test with (20,000…
Anas
  • 5,622
  • 5
  • 39
  • 71
17
votes
2 answers

How to zip only files and not the full path hierarchy with DotNetZip in powershell?

I'm trying to zip up log using DotNetZip and powershell. The files are in C:\user\temp\logs When I loop through the logs in the directory and add them to the zip file, I end up with the folder hierarchy and the log files when I only want the log…
ProfessionalAmateur
  • 4,447
  • 9
  • 46
  • 63
15
votes
4 answers

Using ASP.NET Web API, how can a controller return a collection of streamed images compressed using DotNetZip Library?

How can I create a Web API controller that generates and returns a compressed zip file streamed from a collection of in-memory JPEG files (MemoryStream objects). I'm attempting to use DotNetZip Library. I found this example:…
CalvinDale
  • 9,005
  • 5
  • 29
  • 38
12
votes
5 answers

Downloading of zip file through ASP.NET MVC using DotNetZip

I have created a text file in a folder and zipped that folder and saved @same location for test purpose. I wanted to download that zip file directly on user machine after it is created. I am using dotnetzip library and have done…
user2801336
  • 187
  • 1
  • 2
  • 10
12
votes
1 answer

Zip file is getting corrupted after uploaded to server using C#

I am trying to upload a zip file to server using C# (Framework 4)and following is my code. string ftpUrl = ConfigurationManager.AppSettings["ftpAddress"]; string ftpUsername = ConfigurationManager.AppSettings["ftpUsername"]; string ftpPassword =…
Praveen
  • 55,303
  • 33
  • 133
  • 164
12
votes
2 answers

DotNetZip Saving to Stream

I am using DotNetZip to add a file from a MemoryStream to a zip file and then to save that zip as a MemoryStream so that I can email it as an attachment. The code below does not err but the MemoryStream must not be done right because it is…
user229133
  • 469
  • 2
  • 6
  • 16
1
2 3
30 31