ExtractAll() sometimes throwing an IOException

Dec 23, 2009 at 12:56 AM

I am having a somewhat intermittent issue with ExtractAll (both in 1.8 and 1.9). 

the exception looks as follows:


exception: [IOException]
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password)
   at Ionic.Zip.ZipEntry.Extract(String baseDirectory)
   at Ionic.Zip.ZipFile._InternalExtractAll(String path, Boolean overrideExtractExistingProperty)
   at Ionic.Zip.ZipFile.ExtractAll(String path, ExtractExistingFileAction extractExistingFile)

the code I am using looks similar too:

public void Unzip()
	string[] files = Directory.GetFiles( RootDownload );

	if ( null != files && files.Length > 0 )
		int count = 0;
		foreach( string path in files )
			using( ZipFile zip = ZipFile.Read( path ) )
					zip.ExtractAll( RootData + "\\" + count.ToString(), ExtractExistingFileAction.OverwriteSilently );
				catch( Exception e )
					sTrace.Error( e, "failed to extract: {0}", path );

			sTrace.Info( "finished extracting: {0}", files );

this is just "test" code to try and figure out why i am getting IOExceptions when I try to extract these files (so don't be alarmed that I am naming the directories using a "count" variable). the rub is that the extract PARTIALLY happens. i end up with some of the content extracted into my designated directory before the exception happens. It's not running out of space -- it fails, I catch the exception and then begin to extract the next one which, again, fails part way through. I am seeing this behavior on a windows 6.5 emulator using a windows c:\temp directory as my storage card (the zip files and where i am extracting to are both on this "storage card" which is just my c:\temp directory).

i am using the Ionic.Zip.CF.dll and i tried both 1.8 and 1.9. there doesn't seem to be a lot of buttons to push so I am a little perplexed what might be going on. I feel like this is failing a little too much to be an issue with the library and is most likely something i am doing wrong... has anyone seen this kind of behavior before and have a clue what i might be doing wrong?

thanks in advance,




Dec 23, 2009 at 2:03 AM

I am trying to dig deeper to find out what might be wrong; I used


bool test = ZipFile.IsZipFile( path, true );

and i am getting false for all my zip files. we are constructing the zip files ourselves but we're just using the compression code built into java. is there a way I can dig deeper to see exactly why DotNetZip thinks these files are invalid? i tried wiring up the ReadProgress event handler but I don't receive any meaningful data. Does anyone have any sample code that meticulously winds its way through a zip file and reports the issues so that we can try to fix the compression we're using?




Dec 24, 2009 at 1:29 PM

Seems like you have 2 questions. In the prior one, you are getting exceptions creating a filestream. Seems like a file system permissions error. Can you create a file on the target directory?

The second question is something totally different.  DotNetZip thinks the zip files are invalid.

For the 2nd Q, if I were you I would verify your zip files on the desktop library, first. 

In the latest DotNetZip there's a readonly ZipFile.Info property, a string, that tells you all about the entries within the zip.  That might be a good place to start.

You say "we're just using the compression code built into java."  Would that be java.util.zip?  If not why not?  If so, can you simplify the file that you're compressing in Java?  Make it a simple text file, at first.

Does the zip file open in other tools?  like WinZip?