MemoryStream ms1 = new MemoryStream();
using (ZipArchive archive = new ZipArchive(ms1, ZipArchiveMode.Create, false, null))
{
using (PdfFileSource fileSource = new PdfFileSource(File.OpenRead(documentToSplit)))
{
string splitDocumentName = "1st page.pdf";
using (ZipArchiveEntry entry = archive.CreateEntry(splitDocumentName))
{
using (PdfStreamWriter writer = new PdfStreamWriter(entry.Open()))
{
PdfPageSource page = fileSource.Pages[0];
writer.WritePage(page);
}
}
}
}
File.WriteAllBytes("exported.zip", ms1.ToArray());
7zip and the Windows arvhiver report Data Error on all the files when the users try to extract an archive created with ZipLibrary and the default LzmaSettings.
Reading a password protected archive by passing a wrong password doesn't notify the user that the password is wrong. Accessing one of the entries in the archive throws a generic "Invalid data" exception. Steps to reproduce: 1. Create a zip file with password. 2. Open the same archive with the API passing wrong password and then try to one of the entries. Observed: InvalidDataException is thrown when trying to read one of the entries in the archive. Expected: The exception should be more meaningful and if possible occur when reading the archive. There should be API allowing to check if the password is correct.