ZipArchive.TestArchive(true) fails after using IO.Compression.ZipFile.CreateFromDirectory() on an Folder with several small textfiles
See original GitHub issueSteps to reproduce
- Use the files in the attached zip to create an zip file using ZipFile.CreateFromDirectory() from the namespace System.Io.Compression.
- Create a new ZipArchive-Object and test it using TestArchive.
ZipFile zipFile = new ZipFile(pathToZipFile); bool success = zipFile.TestArchive(true); zipFile.Close();
- Check the return value.
Expected behavior
The return value should be true because it is a proper archive file.
Actual behavior
The return value is always false.
It turns out that, if I use SharpZibLib to generate the archive (which is not an option for the problem I’m working on), TestArchive returns true. It also succeeds, if I only put an database file of the size of ~500kb into the archive. But if I then add File1.txt and Subfolder1\Subfile2.txt (from Testfiles.zip), it returns false again.
Version of SharpZipLib
v1.1.0.145
Obtained from (only keep the relevant lines)
- Package installed using NuGet
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
.net - c# ZipFile.CreateFromDirectory - the process cannot ...
The zip file is trying to zip all of the contents of the folder, but is written while still reading the folder. This...
Read more >ZipFile.CreateFromDirectory Method
This example shows how to create and extract a zip archive by using the ZipFile class. It compresses the contents of a folder...
Read more >Can you zip a file from the command prompt using ONLY ...
Run this in a command-line window to create a ZIP file named C:\someArchive.zip containing all files in folder C:\test3 :
Read more >Creating Zip Files Easily in .NET 4.5
We will use the updated System.IO.Compression namespace to easily create, update, and extract zip files.
Read more >System.IO - John Nelson's Blog
FileSystem assembly. The following little walkthrough will allow us to use the methods of the ZipFile class to work with a simple zip...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your hint. I took another look and realized, I took the wrong version. Actually, I’m using version 1.1.0.145, which obviously is quiet outdated. In that project, it isn’t referenced as nuget paket as I first thought, so I’m going to fix that issue.
I tried it out in a new project using the current nuget package alongside the same data. This works pretty well, so updating the package should solve the issue.
Thanks for your help.
You can get the errors by supplying a logging callback to the method:
(this is from the tests done in ArchiveDiag, which actually returns
true
for the file).That’s not an official SharpZipLib version… maybe you are using a fork?