77 questions
1
vote
0
answers
47
views
VB.NET ZipArchive from MemoryStream empty on response
For some reason the zip file is always empty.
zipInMemory.Length = 0 but below shows the zip with 2 entries...
zipArchive
`Response.Clear()
Response.BufferOutput = False
Dim zipFileName As String = [...
1
vote
1
answer
119
views
Could you use System.IO.Abstractions to treat the differences between a ZipArchive and an actual file system folder transparently?
I have a program that works with projects consisting of multiple files. Each project is saved in a folder of the same name, with project file of the same name, plus one or more support files.
C:\...\...
1
vote
1
answer
66
views
Extensions in subdirectories are not excluded in Zip archive
I have a folder with many sub directories I want to exclude some extensions, but they are only excluded from the first directory level, how to exclude from all directories.
Example of Directory (...
0
votes
1
answer
123
views
PowerShell - Extract file version and date modified from from file in Zip file
I am trying to get the file version from binaries and the date modified from the SQL file and encountered issues
This is my ZIP
$vipFile = Get-ChildItem -ErrorAction Stop -Path "C:\Patch_2029274....
1
vote
1
answer
146
views
How to set CompanionFile attribute for auto-harvested files in WiX toolset?
I am working on a project where I need to handle version downgrades of System.IO.Compression.Native.dll in an MSI installer. This issue was discussed on GitHub, where it was suggested to use the ...
2
votes
1
answer
870
views
Zlib compression in Powershell
I need to compress a string to Zlib in PowerShell.
Is there a way we can compress using the ZLibStream class in PowerShell?
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression....
3
votes
2
answers
161
views
Avoid disk usage as an intermediate step for Zip Compression in C#
The official C# documentation states, that ZipFile.CreateFromDirectory() creates a zipfile on the disk, as an intermediate step. However I need my system to run on devices where disk space is critical....
1
vote
0
answers
182
views
Azure Function Could not load file or assembly
I am writing a function that grabs & decompresses a value from Redis using a key. So far I am able to successfully grab the value, however when I try to decompress the value using GZipStream, it ...
0
votes
0
answers
201
views
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....
0
votes
1
answer
679
views
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 = ...
1
vote
0
answers
381
views
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 ...
1
vote
1
answer
849
views
Read zip file with powershell
is there any faster way to filter a zip file? My code reads the file line by line, so the data loads very slowly. Can I filter more than one line at a time?
$ZipPath = 'C:\Test\TestZip.zip'
Add-Type -...
3
votes
1
answer
766
views
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 ...
2
votes
2
answers
2k
views
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 ...
5
votes
2
answers
9k
views
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 ...
1
vote
1
answer
204
views
Modify and ZIP file in one statement
PSVersion 5.1.18362.2212
I would like to know if it is possible to read in a set of text files, modify their content and their filenames and store the results directly into a ZIP file?
The following ...
10
votes
2
answers
15k
views
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 ...
10
votes
3
answers
10k
views
Extract a single file from a ZIP archive
I'm using the next code to download some zip archive:
$client = new-object System.Net.WebClient
$client.DownloadFile("https://chromedriver.storage.googleapis.com/$LatestChromeRelease/...
1
vote
2
answers
999
views
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 ...
0
votes
1
answer
659
views
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 ...
2
votes
1
answer
1k
views
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 ...
2
votes
1
answer
2k
views
Modify txt file inside a ZIP file in PowerShell
I have a script that can open a ZIP file and modify the content of a xml file and working good
I want to run for a loop at all the ZIP files and change them but I get an error
$files = Get-ChildItem -...
1
vote
0
answers
765
views
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 ...
0
votes
2
answers
2k
views
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(...
0
votes
1
answer
910
views
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 ...
1
vote
0
answers
434
views
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&...
0
votes
0
answers
371
views
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:\...
2
votes
1
answer
2k
views
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....
0
votes
1
answer
724
views
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 ...
-1
votes
2
answers
565
views
Invalid C# Zip File After Compressing
I am writing a code to compress a ZIP file in C# using the built in .NET library:
using System.IO.Compression;
using System.IO;
But, however, when the compression finishes, the code outputs an invalid ...
3
votes
4
answers
2k
views
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 ...
0
votes
1
answer
1k
views
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....
2
votes
1
answer
2k
views
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 ...
1
vote
0
answers
155
views
Zip file works well but still getting an error System.IO.InvalidDataException: 'End of Central Directory record could not be found.' [duplicate]
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";
...
2
votes
1
answer
1k
views
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 ...
0
votes
0
answers
1k
views
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(...
0
votes
1
answer
96
views
Difficulty Accessing Visible Property Using System.IO.Compression.ZipArchive by reflection
The Library loads and I am able to view the ziparchiveentries in the debugger but I can not access the methods or properties of the ziparchiveentry object array by reflection:
Assembly CompressionLib ...
1
vote
1
answer
535
views
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 ...
1
vote
0
answers
2k
views
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 ...
2
votes
1
answer
728
views
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 ...
0
votes
0
answers
2k
views
Unzip having file name non utf-8 is not extracting in correct name
I am extracting a zip file using system.io.compression in .net 4.5
var path = @"<zipfilePath>";
using (ZipArchive zarc = ZipFile.Open(path, ZipArchiveMode.Read,Encoding.UTF8))
{
...
4
votes
1
answer
4k
views
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 ...
2
votes
1
answer
2k
views
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 ...
0
votes
2
answers
2k
views
C# Unable to unzip files zipped with CreateEntryFromFile
As per this post I'm zipping SQL backup files with the code below:
using (ZipArchive zip = ZipFile.Open("test.bak", ZipArchiveMode.Create))
{
zip.CreateEntryFromFile(@"c:\something.txt", "data/...
1
vote
1
answer
948
views
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....
2
votes
1
answer
313
views
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)
...
1
vote
1
answer
2k
views
ExcelDataReader 3.4 - System.IO.FileLoadException
I'm using ExcelDataReader 3.4 and it work fine on my developer PC, but when used on production PC, I've got this error
System.IO.FileLoadException: Could not load file or assembly 'System.IO....
2
votes
2
answers
223
views
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 = ...
3
votes
1
answer
3k
views
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 ...
0
votes
2
answers
3k
views
How can i generate and download zip file from server in angularJs application?
My code is below:
[System.Web.Mvc.HttpPost]
public ActionResult DownloaZipFile([FromBody] int id)
{
var result = _service.GetDocuments(id);
var downloadFileName = $"Report{...