officefileapi-15244-zip-compression-and-archive-api-examples-how-to-add-comment-to-file.md
To add a comment to a file in an archive, do the following:
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");
}
}
Imports DevExpress.Compression
Public Sub ArchiveWithComment()
Dim path As String = Me.startupPath
Using archive As New ZipArchive()
For Each file As String In System.IO.Directory.EnumerateFiles(path)
Dim zipFI As ZipFileItem = archive.AddFile(file, "/")
zipFI.Comment = "Archived by " & Environment.UserName
Next file
archive.Save("ArchiveWithComment.zip")
End Using
End Sub