This project is read-only.

Zip file that is already in use

Aug 24, 2009 at 2:38 PM

Hi to all. Great lib there!


Is there any way that i can add file which is already in use in my zip archive. I am using VB .net (VS 2008).


Best regards!

Aug 24, 2009 at 7:32 PM

I'm sorry, I don't understand what you mean. Maybe you could elaborate a little.

Aug 24, 2009 at 11:06 PM

Sorry, I was in rush.


I wont to zip a file while it is being used by another process. To be more precise, when I try to zip a *.dbf file while a db connection is open, I am getting this exception: "The process cannot access the file 'C:\Documents and Settings\...\JK06.DBF' because it is being used by another process."


It is imposible to terminate proceses that occupeng the file before archiving, so I need to find another solution.

Aug 24, 2009 at 11:28 PM
Edited Aug 25, 2009 at 11:53 AM


well that's a oracle database file, and it's locked because the dB server is writing to it.  Zipping it, or reading it, is a bad idea, which is why you get the exception.

Your options are:

  • skip the file
  • shut down database server, and then zip it.


Aug 25, 2009 at 8:55 AM

It's not oracle, its a Clipper database file. As I sad, terminating connection or shuting down related application is not an option.

Aug 25, 2009 at 7:45 PM

ok, I've posted a new update of DotNetZip, v1.8.4.22 .

There is now a new property on the ZipFile class, called ZipErrorAction.  Use it to specify what you want to do, in the event the DotNetZip library encounters an IO error (such as the one you saw, "The process cannot access the file 'C:\Documents and Settings\...\JK06.DBF' because it is being used by another process.").  You can specify:

  • Skip the file
  • Retry
  • Throw (which is what it did previously)
  • InvokeErrorEvent

The last option invokes an event handler that you provide.  You can use this to prompt the user, for example, to ask what they want to do. 

The new event handler is ZipFile.ZipError. 

At the very least this should provide a simple way for you to skip files that cannot be opened or read.

Let me know what you think.


Aug 26, 2009 at 2:05 PM

I'll do a report as soun as I try. This 'retry' mode seams like will do the job.


Aug 26, 2009 at 5:36 PM

As I thought, 'retry' works like charm. I soppose that lib periodicly check is it file in use and do archiving if not. That was my last planed solution too. But this way is much easier.

I don't know is it bug or something else, but when I call ExtractAll method I got the worning in VS 2008. It says: Warning 1 'Public Sub ExtractAll(path As String, wantOverwrite As Boolean)' is obsolete: 'Please use property ExtractExistingFile to specify overwrite behavior)'

That wosn't isue in previus version.  But, regarding that is working without single error (tested on 4 computers) it is not a problem.


Thanks for intercession, Chesso!

Aug 26, 2009 at 5:47 PM

Glad it's working.

The ExtractAll method that accepts a Boolean will be removed in the next version of the library.  You should use the simpler overload of ExtractAll, the one that accepts a single string.  And specify the behavior you want for existing files, in the property called ExtractExistingFile, available on the ZipFile instance.