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
1
vote
0 answers

Create a directory in a zipFile and add files using C#

The files I want to zip are in different folders The folder structure is as follows: FileId/FileType/File.extension FileId/FileType/File.extension I'm trying to create a zip with the following…
Binoy Cherian
  • 364
  • 1
  • 6
  • 23
1
vote
1 answer

C# ASP System.IO.Compression - Unauthorized access exception when using zipArchive.CreateEntryFromFile for multiple files()

I have the following lines of code that work for creating a zip using ZipFile.CreateFromDirectory(selectedFile, zipPath) if (selectedFolder == string.Empty) { Console.WriteLine("Invalid folder, try again"); } …
casperf1
  • 91
  • 1
  • 8
1
vote
1 answer

Zip Windows 10 Documents folder without including reparse points using System.IO.Compression

I'm writing a simple desktop application to copy files from one PC to another. Having trouble with the Windows 10 reparse points, specifically My Music. I thought was going to get away with one simple line of code:…
A Flynn
  • 47
  • 1
  • 8
1
vote
1 answer

ZipArchive creates invalid ZIP Entry

I'm working with ZipArchive and it's mostly working, the one issue I am seeing is that when the file downloads I cannot open it with windows default archive routines. If I click the zip file and extract all I receive an error message that says…
John Babb
  • 931
  • 10
  • 19
0
votes
0 answers

System.IO.Compression does not accept a bool in "ExtractToDirectory"

I am kinda new to C# and visual studio. I try to unzip a zip and overwrite files if they already exist with the following function: using System.IO; using System.IO.Compression; ZipFile.ExtractToDirectory(gameZip, rootPath, true); But it wont…
0
votes
1 answer

How to avoid random InvalidDataException using System.IO.Compression

I have a .zip file containing three jpg images. I want to display all three of them in one FlowDocumentReader in WPF. This is my code: FlowDocument flowDoc = new FlowDocument(); ZipArchive zipFile = ZipFile.OpenRead("images.zip"); foreach…
Stefan
  • 75
  • 6
0
votes
1 answer

zip multiple directories in Powershell using .NET classes, instead of compress-archive

I am trying to use .NET classes instead of native compress-archive to zip multiple directories (each containing sub-directories and files), as compress-archive is giving me occasional OutOfMemory Exception. Some articles tell me .NET classes, makes…
dig_123
  • 2,240
  • 6
  • 35
  • 59
0
votes
0 answers

Slow performance of ZipFile Method

I'm writing a code to compress/zip folders and files in C#, and for this purpose, I am using ZipFile method from System.IO.Compression. Now if I create a zip file using Winrar (fastest mode), it takes considerably less time to zip the folder and the…
0
votes
2 answers

Copy files from one Zip file to another

I am copying files from one zip file to another in certain circumstances. I am wondering if there is a better way to do it than what I came up with: using FileStream sourceFileStream = new FileStream(source.FileName, FileMode.Open); using FileStream…
a.rlx
  • 54
  • 6
0
votes
1 answer

Azure Block Blob: "The specified block list is invalid." Microsoft.Azure.Storage.StorageException when compressing files > 2GB between Blobs

The issue happens when I upload a file to one blob (Blob1) which in turn runs a background compression service. The background service streams the file from Blob1, compresses it, and stores it as a zip file in a separate blob (Blob2) to cache for…
0
votes
0 answers

Setting ZipArchiveEntry.LastWriteTime loses precision by factor of seconds

I'm trying to set the ZipArchiveEntry.LastWriteTime so that when extracted, it is the 'exact' same time, but I'm getting random time differences. Here is a specific example. var fileName = @"C:\BTR\Publish\ESS\Test\RTX\Global.asax"; var sourceRoot…
Terry
  • 2,148
  • 2
  • 32
  • 53
0
votes
1 answer

Why does System.IO.Compression.ZipFile.ExtractToDirectory() throw InvalidDataException on Artifact.zip from TeamCity?

I recently updated Jetbrains Team City to version 2020.2.2. I use it to build my project whenever I check code into my source repository. I use the TeamCity API to DownloadAll in order to retrieve an Artifacts.zip that contains all the files…
Curtis
  • 5,794
  • 8
  • 50
  • 77
0
votes
1 answer

Can't open zip file created from System.IO.Compression namespace

I'm trying to zip varying amounts of files so that one zip folder can be served to the user instead of them having to click multiple anchor tags. I am using the System.IO.Compression namespace in asp.net core 3.1 to create the zip folder. Here is…
0
votes
1 answer

is it possible to get the size of a zip file while it is being created? CreateEntryFromFile

I would like to know if it is possible to check the size of the zip file that is being created dynamically, because I am reading a directory and generate a 19 MB zip and I would like two zips instead to be created, one 10MB and the other 9MB.…
0
votes
0 answers

How to get progress while compressing a zip file using c# and System.IO.Compression

I need to get the % while compressing a zip file using C# with System.IO.Compression. I have this code: if (isDirectory) { Invoke(new RefreshConsoleEncryptionDel(RefreshConsoleEncryption), "[+]Wait, compressing folder..."); …
KAoTI
  • 37
  • 6