(This is not dotnetzip, but will be executed.)
It is required: using System.IO.Compression;
Assembly: System.IO.Compression.FileSystem.dll
public static bool ZipHasFile(string fileFullName, string zipFullPath)
{
using (ZipArchive archive = ZipFile.OpenRead(zipFullPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(fileFullName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
return false;
}
Call example: var exists = ZipHelper.ZipHasFile(@"zipTest.txt", @"C:\Users\...\Desktop\zipTest.zip");
source
share