Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
Change a Filename before UnzippingHow to open a zip and modify the filename of one or more files within the zip before unzipping.
// Needs #include <CkZip.h> // Needs #include <CkZipEntry.h> CkString strOut; CkZip zip; bool success; // Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial"); if (success != true) { strOut.append(zip.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } success = zip.OpenZip("test.zip"); if (success != true) { strOut.append(zip.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkZipEntry *entry = 0; entry = zip.GetEntryByName("hamlet.xml"); // Assume entry is non-null. If GetEntryByName failed // to find the entry, it returns a null reference. entry->put_FileName("hamlet2.xml"); delete entry; entry = zip.GetEntryByName("helloWorld.pl"); entry->put_FileName("hw.pl"); delete entry; // Now unzip to the "test" subdirectory, under our current // working directory: long numFilesUnzipped; numFilesUnzipped = zip.Unzip("test"); if (numFilesUnzipped < 0) { strOut.append(zip.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // The filenames within the .zip are unchanged, but it unzipped // test/hw.pl and test/hamlet2.xml SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.