System.IO.IOException when using WriteDelegate

May 9, 2014 at 12:11 PM
I wrote a programm that writes multiple files in a loop using a WriteDelegate like this:

Zip.AddEntry(zipFilePath, (name, stream) =>



Inside the delegate I'am writing data using an XmlTextWriter to the file. On my local computer this works perfectly but on some remote virtual computers exceptions are thrown on Zip.Save():

System.IO.IOException the process cannot access the file because it is being used by another process

Why is the zip file still locked after Save() is called? How can I solve this problem? If I just catch the exception and save the file again it seams like the thread is taking the loop variables from the next file. (I've already set an exception in the virus scanner for my application)
May 26, 2014 at 4:45 PM
I solved the problem, now I simply use the ZipOutputStream to add the files in a loop. Using this class I had no more problems and it is even faster!