How to: Add Comment to File
To add a comment to a file in an archive, do the following:
- Create a ZipArchive class instance.
- Call the ZipArchive.AddFile method for each selected file. This method returns an object of the ZipFileItem type.
- Assign a text string to the ZipItem.Comment property.
- Call the ZipArchive.Save method to create an archive and save it to a specified location.
This example adds a text comment to each zip item in the archive that indicates the person who is currently logged on.
using DevExpress.Compression;
//...
public void ArchiveWithComment() {
string path = this.startupPath;
using (ZipArchive archive = new ZipArchive()) {
foreach (string file in System.IO.Directory.EnumerateFiles(path)) {
ZipFileItem zipFI = archive.AddFile(file, "/");
zipFI.Comment = "Archived by " + Environment.UserName;
}
archive.Save("ArchiveWithComment.zip");
}
}