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
2
votes
1 answer

PowerShell reading and writing compressed files with byte arrays

Final Update: Turns out I didn't need Binary writer. I could just copy memory streams from one archive to another. I'm re-writing a PowerShell script which works with archives. I'm using two functions from here Expand-Archive without Importing and…
2
votes
1 answer

System.IO.Compression.ZipArchive keeps file locked after dispose?

I have a class that takes data from several sources and writes them to a ZIP file. I've benchmarked the class to check if using CompressionLevel.Optimal would be much slower than CompressionLevel.Fastest. But the benchmark throws an exception on…
Michael
  • 1,931
  • 2
  • 8
  • 22
2
votes
1 answer

ZipArchive does not flush zip item immediately

I am creating a zip file using ZipArchive + FileStream. When new item is added into zip file, I would like to flush/write newly added item to underneath zip stream. The code below is not flushing the individual zip item. The whole zip gets written…
LP13
  • 30,567
  • 53
  • 217
  • 400
2
votes
1 answer

Zip files without inclusion of folders

I'm using System.IO.Compression in order to compress a file into a .zip, below the source code: using (FileStream zipToOpen = new FileStream(zipName, FileMode.CreateNew)){ using (ZipArchive archive = new ZipArchive(zipToOpen,…
Tytiro
  • 23
  • 4
2
votes
1 answer

Unzip all .zip archives in a directory

I am struggling to configure a script to unzip all .zip archives in a directory and place the extracted files into a different directory. I am wanting to schedule this script to run on a schedule to handle incoming .zip archives. For each .zip…
meckley
  • 21
  • 2
2
votes
1 answer

Why does a CoreRT-compiled program fail to work with ZIP files?

I wrote the following simple program to test: using System; using System.IO; using System.IO.Compression; namespace HelloZip { class Program { static void Main(string[] args) { string path =…
Shay Guy
  • 1,010
  • 1
  • 10
  • 21
2
votes
2 answers

return disposable depending on parent disposable

Here is part of the code i am working on (modified for clarity): public Stream getMyArchiveStream(string archivepath) { using(var archive = ZipFile.OpenRead(_filepath)) { var entry = archive.GetEntry(archivepath); return…
DerMaggi
  • 33
  • 3
2
votes
3 answers

C# .NET Missing Method Exception when opening ZipArchive created with System.IO.Compression

I have a C# WinForms .NET app in which I'm trying to write to a zip archive and read from it using System.IO.Compression. Here's now I create the ziparchive: public void SaveStdV20ZipProject(string strfilepath, clsProjectInfo GameInfo) { …
2
votes
1 answer

System.IO.Compression Zip doesn't use UTC

I've just started using System.IO.Compression in .NET 4.5, and found a problem. It stores the files with a local modification time, not Universal UTC time. So if you zip files in one time zone and unzip them in another, it uses the local…
1
vote
0 answers

Powershell ignore errors, when zipping files

I'm trying to zip specific files however on some files powershell breaks due to the charachter limit of 256, I know I can can alter this y changing registry keys. But I kind of want to ignore this error and write it to a file and zip this error file…
Kirito
  • 49
  • 1
  • 6
1
vote
2 answers

Zip file downloaded from memory stream is empty/invalid

I'm trying to create a tool that takes images on my server, and downloads them to the user in a zip file. These images are Sitecore media items, that I'm getting the Stream from, and trying to copy the streams to a zip file. using…
Erica Stockwell-Alpert
  • 4,624
  • 10
  • 63
  • 130
1
vote
0 answers

Download multiple files as zip threw an exception of type 'System.NotSupportedException'

I am trying to download multiple files in zip format. I've followed every single things that I've found online, but still failed. Here is my code. public FileResult DownloadMultipleFiles(IEnumerable fileName) { //var newfile =…
sicKo
  • 1,241
  • 1
  • 12
  • 35
1
vote
0 answers

Zip file works well but still getting an error System.IO.InvalidDataException: 'End of Central Directory record could not be found.'

I am using the ZipFile method in the System.IO.Compression library. Here is the simple function I have written : public void zipUnzip() { string zipPath = @"C:\zipped_folder.zip"; string extractPath = @"C:\extract"; …
s_om
  • 661
  • 2
  • 9
  • 24
1
vote
1 answer

System.IO.Compression - Counting the number of files using ZipFileArchive is very slow

In order to update a progress bar with the number of files to extract. My program is going over a list of Zip files and collects the number of files in them. The combined number is approximately 22000 files. The code I am using: foreach (string…
Juv
  • 744
  • 7
  • 12
1
vote
1 answer

Why does IO.Compression.ZipFile count of Entries not match 7zip GUI?

I'm trying to verify the contents of a ZIP archive in PowerShell by counting the number of zipped entries like this answer. However, the results are inconsistent between 7Zip GUI, gci, Entries.Count and 7Zip CLI, for example: (Get-ChildItem -path…
Duodenalsalmons
  • 652
  • 1
  • 7
  • 13