Forum Discussion
mr_anto
Jun 16, 2022Copper Contributor
VB.NET. "The process cannot access the file because it is being used by another process"
I should add a list of files into a ZIP. Procedure code is like this Sub CreateZip
Dim FileList As New ArrayList 'List of File Paths to be added to the ZIP
For Each path in FileList
...
IlMinistro
Nov 18, 2022Copper Contributor
mr_anto Sorry if this is late, probably you already fixed it.
Try move
Using zip As Package = System.IO.Packaging.Package.Open(zipFilename, FileMode.OpenOrCreate)
outside of
AddFileToZip
this is because every time you add a file, you try to reopen the zip, which is not very useful.
Open it once, and then add all files to it.