Guest wrote:At irregular intervals I get this error while trying to zip a folder and its sub-folders
How do you specify the folder name when Pack
-ing? Make sure that your working directory is correct when specifying relative paths.
list wrote:There is already a file with the same name in this location.
Obviously, this indicates that a file with same name already exists in the destination ZIP file. There is a flag to automatically preform a rename(if there is conflict) during the CopyHere
routine, however, as mentioned here
Note In some cases, such as compressed (.zip) files, some option flags may be ignored by design.
list wrote:and it always seems to stall at the same file after clicking "copy & replace" a few times.
I've increased the sleep 15 to sleep 50 just to see if that would help but it didn't.
I believe it isn't stalling, the while loop doesn't break because that particular item(file or folder) in the temporary folder(created if the ZIP file is not empty) is not moved. Hence, while (dest.Items().Count != 0)
. In my case though, if I choose Copy and Replace
, the loop breaks, however, if I choose Don't Copy
, I would get the same effect as yours.
The thing with Shell.Application
zipping, esp. for the CopyHere
methods, there is no way to determine if the operation has completed. One would have to resort to checking/comparing the items count, OR if the ZIP file is not empty, temporarily copy/move the files to a temporary folder, then move them to the ZIP file (while checking until the temp folder is empty).
Your issues would only occur if there are file/folder name conflicts so it's best to avoid them for now.