Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.

View Example

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");        
    }
}