If you use
SharpZipLib[
^], you can use the following extension method:
public static void UpdateZip(this ZipFile zipFile, List<string> files)
{
zipFile.BeginUpdate();
foreach(string file in files)
{
if (File.Exists(file))
{
zipFile.Add(file);
}
}
zipFile.CommitUpdate();
zipFile.Close();
}
To call it, all you need do is:
List<string> myList = new List<string>();
myList.Add(@"c:\temp\myfile.txt");
myList.Add(@"c:\temp\myFile2.txt");
ZipFile zip = new ZipFile("path to file");
zip.UpdateZip(myList);