when use 7z, i found the error like this"Wrong update mode" #211
-
my code is c++, like this: std::wstring zipPath = FilePath::Combine(targetPath, targetZipName) + L".7z"; i run it, finally , the error is " failed to zip cache dir. error info: Cannot update the existing archive: Wrong update mode." . my bit7z version is 23.01. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi! If you want to update the existing archive, you need to set the correct compressor.setUpdateMode(UpdateMode::Append); // New items will be appended to the existing archive.
// or
compressor.setUpdateMode(UpdateMode::Update); // New items whose path already exists in the archive will overwrite the old ones, other will be appended. If instead you want to entirely overwrite the existing archive file, you need to set compressor.setOverwriteMode(OverwriteMode::Overwrite); In this case, the existing archive will be replaced with the new one. I just realized that the error message "Wrong update mode" is not exactly clear on which is the issue. I'll probably improve it in a next version of the library. |
Beta Was this translation helpful? Give feedback.
-
As an aside, I've seen you use |
Beta Was this translation helpful? Give feedback.
-
ok, thanks. i try to test this according to your method. thanks. |
Beta Was this translation helpful? Give feedback.
Hi!
The error is due to the fact that the output archive file
zipPath
already exists on the filesystem.By default, bit7z throws an error in such case.
If you want to update the existing archive, you need to set the correct
UpdateMode
:If instead you want to entirely overwrite the existing archive file, you need to set
OverwriteMode
as follows:In this case, the existing archive …