Skip to content

Extraction of password-protected Zip files failed. #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
onepeopleheart opened this issue May 14, 2025 · 1 comment
Open

Extraction of password-protected Zip files failed. #894

onepeopleheart opened this issue May 14, 2025 · 1 comment

Comments

@onepeopleheart
Copy link

Describe the bug

When other programs (such as Bandizip) compress files into password-protected Zip files, using this library to extract them will throw an exception.
When the 'ZipEntry' is fully read, an exception will be thrown on the next read attempt.
ICSharpCode.SharpZipLib.Zip.ZipException: Data descriptor signature not found

`
// An exception will be thrown here.
while ((ze = zis.GetNextEntry()) != null) {
string filePath = Path.Combine(targetFolderPath, ze.Name);
string directoryPath = Path.GetDirectoryName(filePath) ?? string.Empty;

if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath)) {
    Directory.CreateDirectory(directoryPath);
}

if (File.Exists(filePath)) {
    File.Delete(filePath);
}

if (!ze.IsDirectory) {
    long nCur = 0; 
    long nLength = zis.Length;
    OnUnZipEntryStart(ze.Name);
    OnUnZipEntryProgress(0, nLength);
    using (FileStream fs = File.Create(filePath)) {
        int sourceBytes;
        do {
            //An exception will be thrown here.
            sourceBytes = zis.Read(data, 0, data.Length);
            nCur += sourceBytes;
            fs.Write(data, 0, sourceBytes);
        } while (sourceBytes > 0);
    }
}

}
`

Reproduction Code

No response

Steps to reproduce

When the 'ZipEntry' is fully read
On subsequent reads, it is theoretically expected to return 0.
But throw ICSharpCode.SharpZipLib.Zip.ZipException: Data descriptor signature not found

Expected behavior

None

Operating System

Windows

Framework Version

.NET Framework 4.x

Tags

No response

Additional context

No response

@onepeopleheart
Copy link
Author

I found that using FastZip for extraction works fine. What could be the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant