How to: Archive Selected Files
To archive selected files, do the following:
- Create a ZipArchive class instance.
- Call its ZipArchive.AddFile method for each selected file.
- To store a file without its path, call the ZipArchive.AddFile method with the “/“ parameter. The file will be placed in the root node of the archive.
- Call the ZipArchive.Save method. The archive will be created and saved to a specified location.
This code snippet demonstrates how to create a new archive and add files to the archive root. The ZipArchive.Save method compresses data and saves the archive to a file.