User (Old forums)MemberSeptember 23, 2014 at 3:46 pmPost count: 23064
I am creating a zip archive with Xceed.Zip.QuickZip.Zip(@”C:\WorkingDir\Test.Zip”, @”C:\ImportantDir\NecessaryDir\LongNameDir\CustomerDir\”). This is working great. All the sub directories and files are archived.
But when I move “Test.Zip” to “C:\UnzipTest\” and unzip it, it defaults to putting all the files in “C:\UnzipTest\ImportantDir\NecessaryDir\LongNameDir\CustomerDir\”. Is there a way to make it default to unzipping the files into just “UnzipTest” and not all the other directories? There are sub directories under “CustomerDir” so I have to preserve the directory structure (and not just dump all the files into the root). If this isn’t possible to do with QuickZip.Zip, can it be done to the archive after the fact? Can it be done with some other set of Xceed API’s?
Imported from legacy forums. Posted by Atog (had 770 views)Diane [Xceed]ModeratorSeptember 24, 2014 at 12:20 pmPost count: 1353User (Old forums)MemberSeptember 30, 2014 at 11:16 amPost count: 23064Hi;The referenced link suggests using the preservePaths parameter. Unfortunately, I need to preserve the sub-directories in the folder to be zipped, but I do not want to preserve the directories above that. If I set preservePaths to false, it dumps all the files in the root of the zip (causing grief with name duplication). This is why I was asking about changing the root directory of a zip archive. Does this make more sense?Vince
Imported from legacy forums. Posted by Atog (had 80 views)Diane [Xceed]ModeratorSeptember 30, 2014 at 2:42 pmPost count: 1353
You can achieve the effect you are seeking with our FileSystem API.
With it, you can precisely control the portion of the paths you want stored in the zip archive.
// Select the zip file
AbstractFile zipFile = new DiskFile( @”C:\WorkingDir\Test.Zip” );
/* We want to create a new zip file, not update an existing one. As such, any existing
* zip file must be deleted or else the component will attempt to update the existing
* zip file. */
// If the zip file already exists
if( zipFile.Exists )
// Delete it
// Create a logical zip archive around the zip file
ZipArchive zip = new ZipArchive( zipFile );
// Perform a batch update of the zip archive to maximize efficiency
using( AutoBatchUpdate batch = new AutoBatchUpdate( zip ) )
// Select a source folder for files to zip
AbstractFolder sourceFolder = new DiskFolder( @”C:\ImportantDir\NecessaryDir\LongNameDir\CustomerDir” );
// Add the files and sub-folders found the source folder to the root of the zip archive
sourceFolder.CopyFilesTo( zip, true, true );
Imported from legacy forums. Posted by Diane [Xceed] (had 330 views)
- You must be logged in to reply to this topic.