Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create or Update a Zip with Multiple Files
This C# sample code shows how to create or update a Zip compression archive with specific files that have been selected for updating. // Open (or create) a Zip, add files, and save it. private void ZipMultiple_Click(object sender, System.EventArgs e) { Chilkat.Zip zip = new Chilkat.Zip(); zip.UnlockComponent("30-day trial"); if (!zip.OpenZip("MyArchive.zip")) { zip.NewZip("MyArchive.zip"); } // Add individual files. // You will need to modify the AppendFromDir and filenames // before running this sample code. zip.AppendFromDir = "c:\\sampleData"; // Even though the Windows filesystem is not case sensitive, // the Zip entry names (filenames) are case-sensitive. Chilkat.ZipEntry entry = zip.GetEntryByName("dudeZip.BMP"); if (entry != null) { zip.DeleteEntry(entry); } zip.AppendFiles("dudeZip.BMP",false); entry = zip.GetEntryByName("dudeZip2.BMP"); if (entry != null) { zip.DeleteEntry(entry); } zip.AppendFiles("dudeZip2.BMP",false); entry = zip.GetEntryByName("dudeZip3.BMP"); if (entry != null) { zip.DeleteEntry(entry); } zip.AppendFiles("dudeZip3.BMP",false); // ... append any number of files... // Now save the Zip and close it. bool success = zip.WriteZipAndClose(); if (!success) { MessageBox.Show(zip.LastErrorText); } else { MessageBox.Show("Updated Zip Archive"); } }
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.