Questions tagged [system.io.compression]

a compression library for handling zip files and other formats built into .NET framework 4.5 or greater.

System.IO.Compression is a namespace provided as part of the .NET framework for handling some compressed file formats.

The formats supported are

  • GZip (stream)
  • Deflate (stream)
  • Zip

Full documentation can be found on MSDN's website at https://msdn.microsoft.com/en-us/library/system.io.compression(v=vs.110).aspx

64 questions
38
votes
7 answers

ZipArchive gives Unexpected end of data corrupted error

I'm trying to create a zip stream on the fly with some byte array data and make it download via my MVC action. But the downloaded file always gives the following corrupted error when opened in windows. And this error when I try to xtract from…
Faraj Farook
  • 14,385
  • 16
  • 71
  • 97
38
votes
3 answers

How to tell if a "ZipArchiveEntry" is directory?

I am handling some 3rd party ZIP files with .Net 4.5.2 System.IO.Compression.ZipArchive class and all works nicely. However, I need to tell apart file entries from directory entries, preferably without extracting them first. Is there a way to tell…
spacer
  • 1,347
  • 1
  • 9
  • 20
25
votes
5 answers

Invalid zip file after creating it with System.IO.Compression

I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a zip file through a ASP.NET MVC application. The…
César Lourenço
  • 629
  • 1
  • 5
  • 12
24
votes
2 answers

System.IO.Compression and ZipFile - extract and overwrite

I'm using the standard VB.NET libraries for extracting and compressing files. It works as well but the problem comes when I have to extract and files exist already. Code I use Imports: Imports System.IO.Compression Method I call when it…
user1714647
  • 664
  • 2
  • 7
  • 20
11
votes
1 answer

ZipFile and ZipArchive classes from System.IO.Compression and async I/O

.NET 4.5 has added new classes to work with zip archives. Now you can do something like this: using (ZipArchive archive = ZipFile.OpenRead(zipFilePath)) { foreach (ZipArchiveEntry entry in archive.Entries) { // Extract it to the…
vers
  • 622
  • 2
  • 9
  • 21
7
votes
1 answer

How do I compress files using powershell that are over 2 GB?

I am working on a project to compress files that range anywhere from a couple mb to several gb's big and I am trying to use powershell to compress them into a .zip. The main problem I am having is that using Compress-Archive has a 2 Gb cap to…
6
votes
1 answer

System.IO.Compression End of Central Directory record could not be found

On executing the following code.. I get an exception on the OpenRead statement: End of Central Directory record could not be found. I am however able to open the zip file with no issues through windows explorer. Any thoughts? string zipPath =…
Fiona
  • 1,599
  • 5
  • 24
  • 38
6
votes
3 answers

Adding a directory to an existing .zip file

First of all I would like to say that i've tried looking for the solution to this and I haven't found one where I don't have to unzip, add my folder and then zip again. I am not using any third party libraries. I would like to do this using…
YMIFrozen
  • 165
  • 1
  • 2
  • 11
4
votes
1 answer

Compress large files using .NET Framework ZipArchive class on ASP.NET

I have a code that get all files on a directory, compresses each one and creates a .zip file. I'm using the .NET Framework ZipArchive class on the System.IO.Compression namespace and the extension method CreateEntryFromFile. This is working well…
David Ortega
  • 915
  • 9
  • 25
3
votes
1 answer

In Powershell, using only memory (no disk storage available), how can I create a zip archive of a large text file and attach it to an email message?

In Powershell, I'm trying to create a zip file from a large text string, attach it to an email message, and send it along. The trick is that I need to do it without using local storage or disk resources, creating the constructs in memory. I have…
Tony
  • 2,658
  • 2
  • 31
  • 46
3
votes
1 answer

Problems using System.IO.Compression after upgrading from .Net 4.6.1 to .Net 4.8

We have an Asp.Net MVC project that we have recently upgraded from .Net 4.6.1 to .Net 4.8. It has some dependencies on other projects in our solution that have also been upgraded. The MVC project itself uses System.IO.Compression to zip some files…
Simon Williams
  • 1,016
  • 3
  • 11
  • 27
3
votes
1 answer

Compressing and decompressing very large files using System.IO.Compressing.Gzip

My problem can be described with following statements: I would like my program to be able to compress and decompress selected files I have very large files (20 GB+). It is safe to assume that the size will never fit into the memory Even after…
3
votes
1 answer

Decompression error : The magic number in GZip header is not correct

I am new to System.IO.Compression I am trying to compress and decompress some information. For compression I used code project and it seems to work. I am compressing string at the moment. For decompressing I would like to docompress a Stream This is…
Cybercop
  • 8,475
  • 21
  • 75
  • 135
3
votes
1 answer

C# Write image to ziparchive

I'm writing a C# .NET(v4.6.1) WinForms app that will save a file as a System.IO.Compression.ZipArchive. First, I open an image using a SaveFileDialog() method and then I assign it to variable of type System.Drawing.Image. Then I save the file, start…
manicdrummer
  • 161
  • 3
  • 14
2
votes
2 answers

Can I check the contents of encrypted zip-archive without using password?

I've encrypted .zip archive with some files. Later archive contents must be checked by someone who doesn't know encryption password. Is there any way to do this in powershell? Ubuntu has zip -sf myfile.zip command but I couldn't find any simular in…
1
2 3 4 5