Reputation: 57
Hi folks I'm trying to zip file from a path to another path using ZipArchive and ZipFile but I can't achieve it.
zipped = "C:\Images\zip\file01.ZIP"
file = "C:\Images\file01.BAK"
Using newFile As ZipArchive = ZipFile.Open(zipped, ZipArchiveMode.Create)
newFile.CreateEntryFromFile(zipped, file, CompressionLevel.Optimal)
End Using
I'm getting the error: "C:\Images\zip\file01.ZIP" File is being used by another proccess
I will appreciate the help
Upvotes: 0
Views: 73
Reputation: 4185
Try archive mode Update
instead of Create
for a new entry in a zip archive from an existing file
zipped = "C:\Images\zip\file01.ZIP"
file = "C:\Images\file01.BAK"
Using newFile As ZipArchive = ZipFile.Open(zipped, ZipArchiveMode.Update)
newFile.CreateEntryFromFile(zipped, file, CompressionLevel.Optimal)
End Using
Upvotes: 1