adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.26k stars 479 forks source link

Unzipped files are all corrupted #468

Open ThunderBoltEngineer opened 5 years ago

ThunderBoltEngineer commented 5 years ago

I am using this library in our system, for unzipping various archive file types. Recently, I have noticed that this library fails to properly unpack some zip files.

Here is the code

using (Stream stream = File.OpenRead("180 Walnut Street Core & Shell.zip"))
            using (var reader = ArchiveFactory.Open(stream))
            {
                foreach (var entry in reader.Entries)
                {
                    if (!entry.IsDirectory)
                    {
                        try
                        {
                            entry.WriteToDirectory("WalNut 2", new SharpCompress.Common.ExtractionOptions()
                            {
                                ExtractFullPath = true,
                                Overwrite = true
                            });
                        }
                        catch (Exception exception)
                        {
                            Debug.WriteLine(exception.ToString());
                        }
                    }
                }
            }

It seems to unzip all the content files and write into destination directory but when I open those unzipped files (all PDF files), they are corrupted - contents overwritten by another file, replaced or merged.

I have attached the example zip file here; https://www.dropbox.com/s/8wlaebaotu4c39g/180%20Walnut%20Street%20Core%20%26%20Shell.zip?dl=0

Please check and let me know how to resolve this issue ... This is time urgent issue for us.

Thanks!

adamhathcock commented 5 years ago

I’m on vacation and can’t look at this. I may never. Though I’m thinking about resuming work in this library.

However, time sensitivity isn’t something I’m ever going to help with. Please take the time to learn the code and submit fixes if this is mission critical for you.

adamhathcock commented 5 years ago

The zip file and code worked for me just fine and all the PDFs I saw opened on my mac.