Git Product home page Git Product logo

haf / dotnetzip.semverd Goto Github PK

View Code? Open in Web Editor NEW
546.0 46.0 218.0 6.93 MB

Please use System.IO.Compression! A fork of the DotNetZip project without signing with a solution that compiles cleanly. This project aims to follow semver to avoid versioning conflicts. DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.

License: Other

Ruby 0.41% Smalltalk 0.66% C# 72.39% Makefile 0.02% C++ 0.10% PHP 0.02% HTML 3.37% PowerShell 0.19% JavaScript 0.56% Perl 0.01% Batchfile 0.41% Rich Text Format 19.47% Visual Basic .NET 0.89% VBScript 0.41% Classic ASP 0.13% ASP.NET 0.96%

dotnetzip.semverd's People

Contributors

aartbluestoke avatar alexeischerbakov avatar chrfin avatar darkms avatar dependabot[bot] avatar dosomder avatar eamonnerbonne avatar exbachi avatar haf avatar helios-vmg avatar iainnicol avatar jaykebird avatar joelweiss avatar jonreis avatar jshergal avatar lahma avatar lanceheld avatar leezer3 avatar lgtm-com[bot] avatar lilith avatar numpsy avatar romerod avatar seth-deja avatar shana avatar silversj avatar spocweb avatar thieum avatar uecasm avatar zergmk2 avatar zii-dmg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnetzip.semverd's Issues

ZIP bomb detection

Hi there.

I was wondering: Is there anything built-in that I could use for zip-bomb detection?

Based on this:
http://stackoverflow.com/questions/1459080/how-can-i-protect-myself-from-a-zip-bomb
I don't think that checking the file sizes will be enough.

Looking at the code, I don't see anything related, but I am not 100% sure.

Probably, using a custom Stream (inheriting from FileStream) for ZipEntry.Extract(Stream stream) that counts the extracted file bytes would do the trick but it might be good to include something like this in the library.

I will try to do this and I will post the resulting code here, if it works.

SelfExtractorSaveOptions - Require Admin?

This is a feature request.

I'd like to see an option added to the SelfExtractorSaveOptions class to specify that the produced file requires Admin, or Highest Available when opened.

Due to the way csc.exe is run internally, I cannot use 'AdditionalCompilerSwitches' to specify /win32manifest as this will error. Futhermore, manually adding a manifest after the *.exe is compiled is problematic (using mt,exe /manifest -outputresource). While a registry key could be added for the exe itself, that only works on a per-machine basis and must be set in advance. Also it is weak to changing locations.

There may be situations where users want the self-extracting zip to require admin in order to run properly (e.g. extract to root of C for some reason, or otherwise). This would be a cool feature.

Thanks.

Corrupt ZIP file if calling Save twice with UpdateEntry in between

This issue follows on the following SO question:
http://stackoverflow.com/questions/32733976/corrupt-zip-file-if-calling-save-twice

If you run the following program:

using System.IO;
using System.Text;

public class Program
{
    public static void Main()
    {
        var zipFile = new Ionic.Zip.ZipFile();

        var content1 = new MemoryStream(Encoding.Default.GetBytes("Content 1"));
        zipFile.UpdateEntry("test.txt", content1);

        zipFile.Save("test.zip"); // here the Zip file is correct
        //zipFile = new Ionic.Zip.ZipFile("test.zip"); // uncomment and it works too

        var content2 = new MemoryStream(Encoding.Default.GetBytes("Content 2"));
        zipFile.UpdateEntry("test.txt", content2);

        zipFile.Save();  // after that it is corrupt
    }
}

You end up with a corrupted Zip file as the compressed data is empty.
It seems UpdateEntry is not working correctly in this case.

Windows Store app library error

Could not install package 'DotNetZip 1.9.2'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author

"Save" takes very long time.

I have a function, which takes list of files and save them to zip using ZipFile.Save. Average amount of entries in list - 30-40, total size - 15 - 20 megabytes.

Event log of my app:
16:14:48.3593 [ZipHelper] All files added
16:42:03.2812 [ZipHelper] Zip file created

Function:

public static bool CreateZip(List < string > files, string zipFile) {
try {
if (File.Exists(zipFile)) File.Delete(zipFile);
} catch (Exception e) {
Log.Debug(TAG, "Exception when deleting: " + e);
return false;
}
Log.Debug(TAG, "Creating zip file: " + zipFile);
using(ZipFile zip = new ZipFile(zipFile)) {
zip.BufferSize = 1048576;
zip.BufferSize = 1048576;
zip.CodecBufferSize = 1048576;
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
foreach(string file in files) {
Log.Debug(TAG, "Adding file: " + file);
if (!File.Exists(file)) {
Log.Debug(TAG, "File not exist");
continue;
}
ZipEntry entry = zip.AddFile(file);
entry.FileName = Path.GetFileName(file);
Log.Debug(TAG, "File added");
}
Log.Debug(TAG, "All files added");
try {
zip.Save();
} catch (Exception e) {
Log.Debug(TAG, "Exception when creating: " + e);
return false;
}
Log.Debug(TAG, "Zip file created");
return true;
}
}

Any ideas how to solve this problem?

DLL not strong named

The 1.9.2 release version of Ionic.Zip.dll is not strong named, and so cannot be added to the GAC. Previous versions (i.e. 1.9.1.8) were strong named.

Bug Creating File

El desplazamiento y la longitud están fuera de los límites para esta matriz o el recuento es superior al número de elementos desde el índice al final de la colección de origen.

   en System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
   en Ionic.Zip.ZipEntry.WriteCentralDirectoryEntry(Stream s) en c:\FUENTES\MAIS\MAISV2\MAIS_STA\Zip2\Zip\ZipEntry.Write.cs:línea 277
   en Ionic.Zip.ZipOutput.WriteCentralDirectoryStructure(Stream s, ICollection`1 entries, UInt32 numSegments, Zip64Option zip64, String comment, ZipContainer container) en c:\FUENTES\MAIS\MAISV2\MAIS_STA\Zip2\Zip\ZipFile.Save.cs:línea 615
   en Ionic.Zip.ZipFile.Save() en c:\FUENTES\MAIS\MAISV2\MAIS_STA\Zip2\Zip\ZipFile.Save.cs:línea 193
   en Ionic.Zip.ZipFile.Save(String fileName) en c:\FUENTES\MAIS\MAISV2\MAIS_STA\Zip2\Zip\ZipFile.Save.cs:línea 477

Compile on Mono

    /var/folders/j7/wbmqw81j2_jcfwn6_hh0ltlh4zjfkz/T/tmp67a4ace1.tmp: line 1: ../../PackResources.vbs: Permission denied
/Library/Frameworks/Mono.framework/Versions/3.12.1/lib/mono/4.5/Microsoft.Common.targets: error : Command '../../PackResources.vbs' exited with code: 126.

Crash when loading a valid zip file

Hi

Another zip which crash the lib.

The problem is in file zip/zipentry.read.cs(506), method ProcessExtraField
dataSize is < 0 in this zip file, and it crashes (index out of range).

Temporary fix: break if <0:
//fix 05/15: crash with some valid zip
if (dataSize < 0)
{
break;
}

Test file: http://1drv.ms/1J9yeYG

[TestMethod]
public void crash()
{
using (ZipFile zip = new ZipFile(@"c:\test\fireone.zip"))
{
ZipEntry e = zip.Entries.First();
}
}

SecurityException in Medium trust

I am having SecurityException error in my application on medium trust security level.
Is there a way this framework work in medium trust?

Signed Assembly

I'm trying to figure out what the issue around why a strong name cannot be added to this project.
All the bugs related to this point to bug #3, but that bug is closed.

Is it not just a matter of creating a key as per:

https://msdn.microsoft.com/en-us/library/6f05ezxy(v=vs.110).aspx

Then adding it to the project?

It must not be, otherwise, I'm sure you would have done this.

Could you please tell me what the issue is and if there is anything I can do to help with this workitem?

Split files on memory

I am working with split zip files. When I set MaxOutputSegmentSize, I get multiple split files (.zip + .zN files). Afterwards, those files are uploaded to a database.

In the server, I want to load those files in memory and extract them. I tried to simply append all files together in a memory stream and extract them, but this doesn't seem to work.

Any idea about how I could load every split file in memory and extract it? Thanks in advance.

Zlib_ParallelDeflateStream2 test fails

The test fails with the latest code, so the fix from #24 doesn't work.

Message:

Bad state (invalid stored block lengths)

StackTrace:

at Ionic.Zlib.InflateManager.Inflate(FlushType flush) in DotNetZip.Semverd\src\Zlib\Inflate.cs:line 1690
at Ionic.Zlib.ZlibCodec.Inflate(FlushType flush) in DotNetZip.Semverd\src\Zlib\ZlibCodec.cs:line 358
at Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count) in DotNetZip.Semverd\src\Zlib\ZlibBaseStream.cs:line 477
at Ionic.Zlib.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count) in DotNetZip.Semverd\src\Zlib\DeflateStream.cs:line 561
at Ionic.Zlib.Tests.UnitTest1.Zlib_ParallelDeflateStream2() in DotNetZip.Semverd\src\Zlib Tests\ZlibUnitTest1.cs:line 1848

1.9.2. Stream is closed and disposed immediatelly after Extract(stream)

        var x = new XmlSerializer(typeof(UPLXFile));

        using (var z = ZipFile.Read(path))
        {
            // manifest
            UPLXFile uplx = null;

            using (var sManifest = new MemoryStream())
            {
                var zManifest = z["manifest.xml"];
                zManifest.Extract(sManifest);

                sManifest.Position = 0;   // FAILS HERE with stream already closed

                uplx = x.Deserialize(sManifest) as UPLXFile;
            }
        }

Create signed version of DotNetZip-package

Hi,

Is it possible to create an signed version of the DotNetZip?

The remove of signing after 1.9.1.8 was a breaking change (assembly signature changed) and I like to avoid the need of signing of the third party assembly by my self and keep them up to date. If I found correct the old key for signing exists in this changeset https://dotnetzip.codeplex.com/SourceControl/changeset/12914

And yes, we are needing to have signed assemblies to be able to use binding redirection to use the correct version. The IT department at some customer will not allow unsigned assemblies to be installed.

Can't set default filename encoding for input stream

I am unpacking zip files. The sender uses UTF-8 file names without setting the Unicode bit in the header. I had switched to using the DotNetZip stream input method rather than the file oriented method because of the (now thankfully fixed) problem with entries with the same name but only the case is different. With the file oriented method, I can define the default encoding as UTF-8 and I am good to go. With the stream oriented method, setting the PreferredEncoding on the input stream does nothing. That is a property which is useless.

I suspect this would not be hard to fix, but I don't know enough to know about unintended consequences. Besides, since the file name case problem is fixed (I assume, I have yet to test), I do not think that I need the bug fixed for myself, but I do want to point it out and would probably fix it if I was more comfortable with the library.

P.S.: I am using this library instead of the dot.net framework one because the sender also has the habit of including colons in the middle of file names which makes the MS framework unhappy. I appreciate being able to rename the file before unpacking it.

-- Thank you for listening
-- Jeffrey

Cannot create empty directory

I cannot create empty directory in my zip file by AddDirectoryByName. Please do not say "you don't have to do because other AddXXXX methods creates the directory path automatically." to me. Because by this way still i cannot create empty directory.

.Net Core

Does this library supports .Net Core? if not, any plans to do so in the near future?
I really like this library and it is my go to when it comes to .Net 4.x...
Keep up the good work!

Remove of strong name of assembly causes update issues

We have a package relying on version >=1.9.1.8.
If we now install our package the new version 1.9.2 gets installed because build and revision changes are automatically loaded by NuGet.

These are bugfixes or even less, maybe changes in the NuGet package itself.

The removal of strong naming of an assembly should be a breaking change (http://haacked.com/archive/2012/02/16/changing-a-strong-name-is-a-major-breaking-change.aspx/).

Now. To the error. Assembly version 1.9.1.8 could not be found comes up as a runtime error.
A binding redirect was not added automatically so I added it manually.
Now version 1.9.2 could not be loaded. The exception tells me, that the PublicKeyToken did not match. I checked it. In version 1.9.2 it is null, so strong naming has been removed.

Is this also the reason why NuGet did not add the redirect automatically?

Anyway. I guess it was just a mistake, right? Otherwise it would have been tested and we all would have been on 2.0.

Cant't find a file with SelectEntries

Hi

I use a zip file with several zipped file in it.
One of them is : '1941\sasas (4)' (with a folder and no extension).
When I use SelectEntries with the exact name, I get no responses:

zip.SelectEntries("name='sasas (4)'","1941")
Count = 0

If I add a * to the name, it is found:

zip.SelectEntries("name='sasas (4)*'","1941")
Count = 1
[0]: {ZipEntry::1941/sasas (4)}

Ignore missing files

I'm zipping a large directory. Its possible that after the list of files to zip is compiled that one or more files will have been moved/deleted. Think cache files.

Are you aware of a feature to ignore the missing files? Currently it will throw an error and stop the entire save. This isn't ideal because these files that are no longer there, i no longer care about. And if they simply moved then i will pick them up on the next run.

Alternatively I could append to a zip, or use a ZipOutputStream (like http://stackoverflow.com/a/10849299). However, they increase the amount of code required and I think it would be nicer to just toggle a boolean.

Thoughts?

FileName is wrong when using special characters.

Copying from here (just in case you are interested in this bug):
https://dotnetzip.codeplex.com/workitem/17551

Attachment:
https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=dotnetzip&WorkItemId=17551&FileAttachmentId=6115


Some characters in the file path cause problems.
I attach the test ZIP file.
If you run this code:

            var zip = ZipFile.Read(@"Test.zip");
            var str = string.Empty;
            foreach (var i in zip)
            {
                str += i.FileName + "\r\n";
            }

..you will get this inside str:

Æ¥ æ¢å/
Æ¥ æ¢å/Start à ç é è ê ë î ï ô û ù ü og ÿ End/
Æ¥ æ¢å/Start à ç é è ê ë î ï ô û ù ü og ÿ End/Spesial tegn.txt
ÆØ æøå/Test 1-å Áá Čč Đđ Ŋŋ Šš Ŧŧ Žž End/
ÆØ æøå/Test 1-å Áá Čč Đđ Ŋŋ Šš Ŧŧ Žž End/Spesial tegn.txt
ÆØ æøå/Test 1-å Áá Čč Đđ Ŋŋ Šš Ŧŧ Žž End/Test 1.1/
ÆØ æøå/Test 2 -æ Ελληνικά End/

Notice the 0-level folder names.
They are not correct.
I am not sure why this happens and which characters have this issue...

After some debugging I have located this method:

Ionic.Zip.ZipEntry.ReadDirEntry 

...and this line:

zde._FileNameInArchive = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);

...but no other type of encoding I've tried seems to solve the issue. :(

hi,

hi ,
i develop in asp.net

i have web app that framework is 4.5

i want use self extracting make exe archive ,compile with 4.5
but i want .net 2.0

i what to do ? plz help my

Release 1.9.8?

Hey there! On the NuGet page, it says the latest release is 1.9.8. However, here on GitHub's "Releases" page, the latest is 1.9.3. What commit marks the 1.9.8 release (and/or some of the earlier releases)? Reason asking is I'd like to get the "Reduced" dll for my program, and I'd like to use the 1.9.8 version of this dll, as it is a release; I don't necessarily know what has broken or been made buggy in the development commits between releases.

Also, is there a place that change logs are maintained? There is the change log on the main README file but it doesn't really seem updated at all.

Windows explorer can't open DotNetZip Create Zip File...

Here is the code

            ZipFile zipObj = new ZipFile();
            //zipObj.UseUnicodeAsNecessary = true;
            zipObj.UseZip64WhenSaving = Zip64Option.Always;
            zipObj.AlternateEncoding = Encoding.UTF8;
            zipObj.AlternateEncodingUsage = ZipOption.Always;
            zipObj.EmitTimesInWindowsFormatWhenSaving = true;
            //zipObj.ProvisionalAlternateEncoding = Encoding.UTF8;


            zipObj.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
            zipObj.Comment = loZip.ReMark;
            if (!string.IsNullOrEmpty(loZip.Password))
                zipObj.Password = loZip.Password;

            zipObj.FullScan = true;
            zipObj.SaveProgress += zipObj_SaveProgress;
            fmPS.setMaxValues = lsSource.Items.Count;
            int iRow = 0;
            foreach (string lsFile in lsSource.Items)
            {
                if (File.Exists(lsFile))
                    zipObj.AddFile(lsFile,".");
                else if (Directory.Exists(lsFile))
                {
                    string[] lsFiles = lsFile.Split('\\');
                    zipObj.AddDirectory(lsFile, lsFiles[lsFiles.Length - 1]);
                }
                iRow++;
                fmPS.setProecssValues = iRow;
            }
            if (!string.IsNullOrEmpty(loZip.ChineseReMark))
            {
                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(string.Format(loZip.ChineseReMark)));
                zipObj.AddEntry("ReadMeFirst.txt", ms);
            }
            zipObj.UseZip64WhenSaving = Zip64Option.Always;
            zipObj.Save(loZip.FilePath + "\\" + loZip.FileName);
            return true;

When I use Win7 or Winxp the Explorer to open unreadable error occurs.
But it can be opened using 7Zip normal to see the file.
Is there any way you can solve the thing?

Version 1.9.2: Does not have a strong name.

I did not have this issue with 1.9.1.8 but I'm getting the compiler error below when I add your Nuget package and attempt a build.

CSC : error CS1577: Assembly generation failed -- Referenced assembly 'Ionic.Zip' does not have a strong name

Multi-platform: approach with NuGet packages

I realized a little bit ago that simply adding in new projects and platforms doesn't mean they get automatically added into the NuGet package, so I need to figure out how we can approach this. Lets suppose we want to get iOS and Android out the door; should the build process be modified so that individual NuGet packages are generated for each of those projects? I'm thinking this may be the only/best way to go so I'll start looking into it on my end.

Hang when dealing with a corrupted file

Hi all
After testing hundred of files, I found a file which hang the zip Library.
When I attempt to rename a compressed file, it hangs and never return.
Note that the file to rename is corrupted and should return a zipException as expected.

Here is a short unit test:

    [TestMethod]
    [ExpectedException(typeof(ZipException))]
    public void Hang()
    {
        using (ZipFile zip = new ZipFile(@"c:\test\wizzquiz.zip"))           
        {
            ZipEntry e = zip.Entries.First();
            e.FileName = "newname";
            zip.Save(); //Hang here
        }
    }

And the zip file to use:
http://1drv.ms/1zfhMnw

I hope you can have a look and fix this problem. I didn't check other actions on this file, but the problem may be more general and occur with delete or add.

Consider dual-licensing?

The Ms-Pl is incompatible with many free software licenses, as it imposes a unique restriction:

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. [...]

Many OSI-approved copyleft licenses require that linking or interacting code must be licensed in a manner that does not further restrict user rights. This conflicts with the Ms-Pl, as it specifically prohibits the right to re-license.

There are many GPL, LGPL, and AGPL-licensed libraries, yet we cannot legally combine these with DotNetZip due to the terms of the Ms-Pl.

Dual-licensing under Apache 2 or MIT would resolve the problem. As GitHub notifies people who are mentioned, re-licensing would involve pasting the list of contributors into this thread and asking for a release of their copyright. Getting approval can take anywhere from a few days to several months, depending upon contributor awareness. We would also need to get approval from @DinoChiesa for the original code on SVN.

Thoughts?

Please change the assembly name back to Ionic.Zip.dll

This seems like a bad decision:

  1. There is no way of writing a bindingRedirect to an assembly name that has changed so existing applications that use our framework may break.
  2. The main namespace of the library is Ionic.Zip which one would expect the library to be Ionic.Zip.dll
  3. It adds no apparent value to change the name, so why change it

I very much appreciate this library, just questioning why the name change.

hang at Ionic.Zlib.ParallelDeflateOuputStream

using Ionic.Zip 1.9.9.0 (and 1.9.3, i refreshed to latest library to test) the following code hangs at zip.Save()

{
  using (var zip = new ZipFile(m_Args.TmpFile)) 
          {
            zip.UseZip64WhenSaving = Zip64Option.Always;
            zip.ParallelDeflateThreshold = 0;
            zip.Password = m_Args.ClearTextPassword; 
            zip.Encryption = EncryptionAlgorithm.WinZipAes256;

     foreach (var f in m_Args.Files)
      {
        zip.AddEntry(f, (E,S)=>WriteFileEntry(S,...)); // multiple files here, this code is slightly simplified from the production code this was taken from
    }

            // this is when it all hangs on completion of a file
           // stack trace below shows that 100% of runtime is now spent on waitOne after completion of the run (logger and runtime before getting to this point show the the expected output has been created, but it just hasn't cleaned up)
            zip.Save();
}

WriteFileEntry(System.IO.Stream a_To, ...){
 a_To.Write(data, 0, data.Length); // and so on
 a_To.Flush();
}

Attaching a profiler after it has hung shows that the main thread is waiting inside save, on the stream close. I believe this is at the end of the first file, as the status bar on the app doesn't get to "zipping file 2/5", but the last row log shown is the end of the first file.
image

An ArgumentOutOfRangeException is thrown in some cases while extracting

In one of our modules we use Zip compression and extraction to efficiently store some informational data in lower-level devices. In several cases our users reported a strange error while reading back this data.

I've investigated the case and I've found that these lines fail with an ArgumentOutOfRangeException because the Int64 value is invalid.

ZipEntry.Read.cs: 785

z = BitConverter.ToInt64(buffer, j);
this._Ctime = DateTime.FromFileTimeUtc(z);
j += 8;

As I've further investigated the sources, I've found that it once runs correctly, and second times it fails. It is called second time within a block in ZipFile.Read.cs:797, where it's noted, that "errors are ignored because data might be corrupted". I can see the two empty catch blocks which hides two type of exceptions.

try {
   ...
}
catch (ZipException) { }
catch (IOException) { }

However, this exception is a third type, which gets through and causes a crash. I've also tested that if I overwrite the read long value while debugging, I get another ZipException later, but that gets swallowed, and I get my correct data.

It seems to me that it's a small but very painful bug in the code, but please correct me if I'm wrong and in that case give some tips what can cause this issue.

Thank you for your time,
Zoltán

Process hangs in Save-method.

I found similar issue reported on codeplex: Deadlock in ParallelDeflateOutputStream.EmitPendingBuffers.

Bug is replicated constantly.

for (int i = 0; i < 10; i++){
    Console.WriteLine(i);
    if (File.Exists("d:\\test.zip")) File.Delete("d:\\test.zip");
    using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile("d:\\test.zip")){
        var entry1 = zip.AddFile(@"wbxtra_08142014_143601.wbt", "1");
        var entry2 = zip.AddFile(@"wbxtra_08182014_171855.wbt", "2");
        zip.Save();
        Console.WriteLine("Saved.");
    }
}

Bad signature (0x6F9E597E) at position 0x00AF8F62

The error is coming at the moment when i make --> input.GetNextEntry() by Extracting from this ZIP

https://www.dropbox.com/s/ckli5dv3kzmk6gj/sample.zip?dl=0

Can anybody help me?

my code for extracting:

byte[] buffer = new byte[2048];
int n;

using (var raw = File.Open(zipFilePath, FileMode.Open, FileAccess.Read))
{
    using (var input = new ZipInputStream(raw))
    {
        if (!string.IsNullOrEmpty(password))
            input.Password = password;

        ZipEntry entry;

        while ((entry = input.GetNextEntry()) != null)
        {
            if (entry.IsDirectory) continue;

            string outputPath = Path.Combine(targetPath, entry.FileName.Split(new []{ '/'}).Last());

            using (var output = File.Open(outputPath, FileMode.Create, FileAccess.ReadWrite))
            {
                while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    output.Write(buffer, 0, n);
                }
            }
        }
    }
}

Async/Await support

Are there any plans to support asynchronously compress/extraction preferably using async/await keywords?

CHM Help file

Hello,

where can I get the CHM Help file for this library? It's not included in the NuGet package and I can't find a download link on the GitHub project page.

Thanks!

Folders

When I am adding files using a stream and I want to create a folder structure of files this way there is a problem with the folders. It will create the paths in the zip file for the files but I cant get it to actually create the folder entries in the zip. How can I create the folder entry without the file system? This is an issue with opening this with other systems.

Save progress restart

hi, I found the SaveProgressEventArgs.BytesTransferred can restart in a same file sometimes, and it is easy to recurrence. The lib vsersion : DotNetZip.1.9.8, I get it from NuGet.

I print the message into "D:\BatchPackager.log":

Writing: OTAPkg-v1.0.0-win7-x86_32-9A536913612FC77139551AF68F19DBC4.zip (1/6)
855/855 (100%)
Writing: test-316AD501BA539E5E9B5460DF2C02E03D.zip (2/6)
32768/164181 (20%) <------------ here start
65536/164181 (40%)
98304/164181 (60%)
131072/164181 (80%)
163840/164181 (100%)
164181/164181 (100%) <------------ here completed
32768/164181 (20%) <------------ here restart
65536/164181 (40%)
98304/164181 (60%)
131072/164181 (80%)
163840/164181 (100%)
164181/164181 (100%)
Writing: test1-22332A342B7F0BCC8E0D7B311FDA7FE7.zip (3/6)
32768/164185 (20%) <------------ here start
65536/164185 (40%)
98304/164185 (60%)
131072/164185 (80%)
163840/164185 (100%)
164185/164185 (100%)
32768/164185 (20%) <------------ here restart as a smae size : 32768bytes == 32kb, why?
65536/164185 (40%)
98304/164185 (60%)
131072/164185 (80%)
163840/164185 (100%)
164185/164185 (100%)

Here is my progress event handler
`
private static bool justHadByteUpdate = false;
private static void DefaultSaveProgress(object sender, SaveProgressEventArgs e)
{
string msg = string.Empty; //debug
if (e.EventType == ZipProgressEventType.Saving_Started)
{
Console.WriteLine("Saving: {0}", e.ArchiveName);

            msg = string.Format("Saving: {0}", e.ArchiveName); //debug
        }
        else if (e.EventType == ZipProgressEventType.Saving_Completed)
        {
            justHadByteUpdate = false;
            Console.WriteLine();
            Console.WriteLine("Done: {0}", e.ArchiveName);

            msg = string.Format("Done: {0}", e.ArchiveName); //debug
        }
        else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
        {
            if (justHadByteUpdate)
                Console.WriteLine();
            Console.WriteLine("  Writing: {0} ({1}/{2})",
                              e.CurrentEntry.FileName, e.EntriesSaved, e.EntriesTotal);
            justHadByteUpdate = false;

            msg = string.Format("  Writing: {0} ({1}/{2})",
                              e.CurrentEntry.FileName, e.EntriesSaved, e.EntriesTotal); //debug
        }
        else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
        {
            if (justHadByteUpdate)
                Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write("     {0}/{1} ({2:N0}%)", e.BytesTransferred, e.TotalBytesToTransfer,
                         e.BytesTransferred / (0.01 * e.TotalBytesToTransfer));
            justHadByteUpdate = true;
            msg = string.Format("     {0}/{1} ({2:N0}%)", e.BytesTransferred, e.TotalBytesToTransfer,
                         e.BytesTransferred / (0.01 * e.TotalBytesToTransfer)); //debug
        }
       // debug
        if (msg.Length > 0)
        {
            StreamWriter fs = File.AppendText("D:\\BatchPackager.log");
            fs.WriteLine(msg);
            fs.Flush();
            fs.Close();
        }
    }

`

System.UnauthorizedAccessException: Access to the path is denied

In my code I have a method:

public bool CreateZIP(string ListStep)
{
    Logger logger = LogManager.GetLogger("Task:CreateZIP" + this.TaskGuid);

    using (ZipFile zip = new ZipFile())
    {
        zip.AlternateEncoding = System.Text.Encoding.GetEncoding("cp866");
        zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always;

        ...
        zip.AddFile(...) loop
        ...

        zip.MaxOutputSegmentSize = Properties.Settings.Default.ZIPSizeLimit * 1024 * 1024;

        string zipFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"zip-tmp");
        string TaskZipFolder = Path.Combine(zipFolder, this.TaskGuid);

        try
        {
            if (!Directory.Exists(zipFolder)) Directory.CreateDirectory(zipFolder);
            if (!Directory.Exists(TaskZipFolder)) Directory.CreateDirectory(TaskZipFolder);

            zip.TempFileFolder = Path.GetTempPath();
            zip.Save(Path.Combine(TaskZipFolder, this.TaskGuid + @".zip"));
        }
        catch (Exception e)
        {
            logger.Fatal("Unable to save ZIP into ({0}): {1}", Path.Combine(TaskZipFolder, this.TaskGuid + @".zip"), e.ToString());
            throw;
        }
    }
    return true;
}

This code is running on remote server from domain user gfo-svc from C:\Courier\WD directory.
Each object instance has it's GUID, for example e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55
So the zipFolder variable value is C:\Courier\WD\zip-tmp and TaskZipFolder value is C:\Courier\WD\zip-tmp\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55

When this code tries to run it fails with this stack trace:

Unable to save ZIP into (C:\Courier\WD\zip-tmp\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55.zip): System.UnauthorizedAccessException: Access to the path is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.__Error.WinIOError()
   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
   at Ionic.Zip.ZipSegmentedStream.TruncateBackward(UInt32 diskNumber, Int64 offset)
   at Ionic.Zip.ZipEntry.Write(Stream s)
   at Ionic.Zip.ZipFile.Save()
   at Ionic.Zip.ZipFile.Save(String fileName)
   at Worker.Task.CreateZIP(String ListStep) in Worker.cs:line 844

But in the C:\Courier\WD\zip-tmp\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55 folder I can see file e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55.z01, so the first part of archive was saved before failure.

gfo-svc user has ownership on C:\Courier\WD directory and my code could create 'zip-tmp' directory if it is not exists, and GUID-named directory in it. So the problem is not in Windows Security permissions.
UAC on this remote server is disabled.

What could I do wrong? What might be wrong with my environment? What could I do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.