I am adding files from various locations to a zip file. These files can potentially have the same name, so I am trying to version the those (adding (1), (2), etc to the name), but only within the zip file.
I am also specifying the path hierarchy within the zip file.
So, for example:
using (ZipFile zip = new ZipFile())
foreach (FileCollection dir in dirs)
var zipPath = path1 + "/" + path2 + "/";
foreach (FileObject file in files)
var newName = file.Filename + "(1)";
zip.AddFile(file.FullPath, zipPath).FileName = newName;
This doesn't work. I get an exception saying "An item with the same key has already been added."
If I remove the zipPath when calling the AddFile method, like so:
zip.AddFile(file.FullPath).FileName = newName;
...everything works fine.
This, it seems like the FileName setter is not working whenever the AddFile overload method is used.