I have some code that adds different directories to a zip file. Its important that I know each folder based on its comment, during the extraction process. Here is the zip sample code:
foreach (string folder in BackupDIRS)
{
string Source = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), folder);
string Folder = Path.GetFileName(Path.GetDirectoryName(Source));
ZipEntry e = zip.AddDirectory(Source, Folder);
e.Comment = "comment here";
}
Here is the code for unzipping:
using (ZipFile zip1 = ZipFile.Read(src))
{
foreach (ZipEntry e in zip1.Entries)
{
// e.comment will be null on actual files.
}
}
The actual entry points for the folder have comments but their files dont, which presents a problem since it will cause most entries to have null comments.
How do I make the files have the same comment as the folder, or does DotNetZip extract directory files sequentially, meaning if its null I could use the last non null value because it would be that folder's files.
After calling
ZipEntry e = zip.AddDirectory(Source, Folder);
you can iterate through all files inZipEntry
and assign a comment:Hope it helps.