This project is read-only.

Zipping very small files causes incorrect state

Jul 21, 2009 at 6:01 PM
Edited Jul 21, 2009 at 6:03 PM

I am trying to use the framework, which is really nice and easy to use.

How ever I am getting a race condition where a process is trying to archive a lot of files and in the process running into a "being used state".

The files are very small, they also can be compressed into a zip file that indicates a 0 byte size.  (mainly a text file that has 3 or 4 lines of text).

I am at a stand still on how to determine if the zip file is in use before I start to add files to the archive.  An error "File is not in correct state for this action.  Could not read signature - no data!" blocks all of the subsequent attempts to add files.

I can start off with a very larg file and have no problems.  I am sure that I will probably use some kind of blocking process to keep this from happening, but it would be very nice if some IO access features could be added so that the Ionic Zip Utility can give indication or block automagically.

 Also -- Edit

if you don't have Windows Mobile 6 Standard SDK installed, you are pretty much scruud...  I am not able to build the source from the solution.

If anyone has ran into this maybe a suggestion that I am not seeing?

Jul 21, 2009 at 7:28 PM

Last thing first:  Yes, if you want to build the source, without change, you need to download the Windows Mobile 6 Standard SDK.  That is a free download.  If you don't have and don't want the Mobile 6 SDK, I think you need only to remove the CF projects.  Just delete them from the solution.  There are four relevant projects;  ZLIB CF, ZIP Partial CF, ZIP Full CF, and the CF Unzipper.   Then you should be able to build the solution normally. 

About the race condition - I totally don't understand the error you are getting.  Do you get an exception?  if so, can you post the stacktrace? 

Also a guess based on your brief description": I think you are using the ZipFile constructor that accepts a zipfile name as an argument, is that right?  You may not be clear on this but the named file should be either a valid zip file on the disk, or the name of a file that does not exist.  If you pass the name of a file that is empty, for example, to that constructor, the constructor will throw an exception. Some code:

This example will open an existing zip archive, add a single file to the archive, and then save it as the same name. The file, once saved, will have n+1 entries, where n is the number of entries present in the zipfile before running this code.

using (var zip = new ZipFile(filename))

This example will create a new zipfile, add a single file, and save it. The zip file will have 1 entry in it. The Save() will overwrite any existing file.

using (var zip = new ZipFile())