Xceed Zip Compression Library Documentation
BasePath property example
Example topics > BasePath property example

Let's say you want to zip all the .BMP files in the "C:\SERVER5\COMMON\DATA\BITMAPS\" folder, but you only want the "DATA\BITMAPS\" portion of the path to be stored before each filename. Note the following code:

Visual Basic Copy Code

XceedZip1.ZipFilename = "C:\TEMP\TEST.ZIP"
XceedZip1.FilesToProcess = "C:\SERVER5\COMMON\DATA\BITMAPS\*.BMP"
XceedZip1.PreservePaths = True

ResultCode = XceedZip1.Zip

'If you use the above code, your files will be stored in the zip file with the following (incorrect)
' path and file names (the drive letter and colon are always discarded):

'"SERVER5\COMMON\DATA\BITMAPS\PICTURE1.BMP"
'"SERVER5\COMMON\DATA\BITMAPS\PICTURE2.BMP"

'To get the desired results, use the following code:

XceedZip1.ZipFilename = "C:\TEMP\TEST.ZIP"
XceedZip1.BasePath = "C:\SERVER5\COMMON"
XceedZip1.FilesToProcess = "DATA\BITMAPS\*.BMP"
XceedZip1.PreservePaths = True 

ResultCode = XceedZip1.Zip 

'The files will then be stored with the following (correct) path and filenames instead:
'"DATA\BITMAPS\PICTURE1.BMP"
'"DATA\BITMAPS\PICTURE2.BMP"