How to: Add Comment to File

To add a comment to a file in an archive, do the following:

  1. Create a ZipArchive class instance.
  2. Call the ZipArchive.AddFile method for each selected file. This method returns an object of the ZipFileItem type.
  3. Assign a text string to the ZipItem.Comment property.
  4. 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("Documents\\ArchiveWithComment.zip");

            }
        }