It depends on the classes you use. If you use the QuickZip class, then you can use the preservePaths parameter of one of the overloaded Zip() method to have the path preserved when constructing the zip archive.
If you use the FileSystem classes (i.e. ZipArchive), there is no such property. To preserve paths in this case, you need to use the CopyTo() method rather then the CopyFilesTo() method.
e.g.:
AbstractFile zip = new DiskFile( @”D:\Temp\Paths.zip” );
ZipArchive archive = new ZipArchive( zip );
AbstractFolder folder = new DiskFolder( @”D:\Temp\temp” );
//This will keep paths
folder.CopyTo( archive,
true );
//This will not keep paths
folder.CopyFilesTo( archive,
true, true );
Imported from legacy forums. Posted by André (had 1286 views)