/// <summary>
/// Add files to an existing Zip archive,
/// </summary>
/// <param name="filename">Array of path / filenames to add to the archive</param>
/// <param name="archive">Zip archive that we want to add the file to</param>
public void AddToZip(string[] filename, string archive)
{
if (!File.Exists(archive))
{
return;
}
try
{
ZipFile zf = new ZipFile(archive);
zf.BeginUpdate();
// path relative to the archive
zf.NameTransform = new ZipNameTransform(Path.GetDirectoryName(archive));
foreach (var file in filename)
{
// skip if this isn't a real file
if (!File.Exists(file))
{
continue;
}
zf.Add(file, CompressionMethod.Deflated);
}
zf.CommitUpdate();
zf.Close();
}
catch (Exception e)
{
if (e.Message != null)
{
var msg = new[] { e.Message };
LocDB.Message("defErrMsg", e.Message, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
}
}
}