I'm using Telerik in an interop environment with C++ and trying to replace our old ZIP library. With the code below it appears to ZIP all files correctly except the last file always has some error with it like it isn't being written out properly. I've changed the number and type of files and the specific file type doesn't matter, the last one in the archive is always corrupted when i test the archive.
System::String^ sSource = gcnew System::String(m_sPath1);
System::String^ sDest = gcnew System::String(sZipDest);
System::IO::File^ file = nullptr;
System::IO::Stream^ stream = file->Open(sDest, System::IO::FileMode::Create);
Telerik::Windows::Zip::ZipArchive^ zarchive = gcnew Telerik::Windows::Zip::ZipArchive(stream, Telerik::Windows::Zip::ZipArchiveMode::Create,
false
,System::Text::Encoding::UTF8);
Telerik::Windows::Zip::DeflateSettings^ compressionSettings = gcnew Telerik::Windows::Zip::DeflateSettings();
compressionSettings->CompressionLevel = Telerik::Windows::Zip::CompressionLevel::Best;
compressionSettings->HeaderType = Telerik::Windows::Zip::CompressedStreamHeader::ZLib;
pList3->ResetContent();
rc = 0;
nCount = pList1->GetCount();
for
(n = 0; n<nCount; n++) {
pList1->GetText(n, sFileName);
sFullyQualifiedFileNameFrom = fs.AppendWildcard(m_sPath1, sFileName);
int
nSel = pList3->AddString(sFileName);
pList3->SetCurSel(nSel);
pList3->UpdateWindow();
System::String^ sFull = gcnew System::String(sFullyQualifiedFileNameFrom.GetBuffer());
System::String^ sName = gcnew System::String(sFileName.GetBuffer());
Telerik::Windows::Zip::Extensions::ZipFile::CreateEntryFromFile(zarchive, sFull, sName, compressionSettings);
int
nFilesPercent = 100 * (n + 1) / nCount;
m_prStatus.SetPos(nFilesPercent);
}
Sleep(5000);
stream->Flush();
stream->Close();
Is there something else that should be done to finish the compression/writing of the last file when in the loop using CreateEntryFromFile?