I actually wrote this in Vb.Net 2008 and posted a question over at VbForums in the Vb.Net area but no joy in finding a hint at an answer so I thought I would try it here since there should not be much difference in the troublesome code between VB.Net and C#

Code:

Using ZP1 As ZipFile = New ZipFile(FileName)
ZP1.ZipErrorAction = ZipErrorAction.Throw ' have tried it without this line no difference
ZP1.AddDirectory(Folder)ZP1.Save() ' hangs here
ZP1.Dispose()
End Using

Assume that filename and folder are defined and populated with a valid path/filename before it gets to this point.

The problem is that the code above seems to work fine on most folders but there are a couple of folders where it just hangs on the save line.
This is part of a little archive program I wrote for personal use to make archive copies of projects which have been changed since the last backup.
Anyway there are a bunch of folders on the system and those fodlers all contain sub folders. If I have it process them all it will go throw the first 27 projects without an issue then hang on the 28th project. If I turn off the Archive Bit on that project then it makes it through 97 projects and hangs on the 98th one.

I made another routine to test which does only one project which works fine on all except those 2 projects. It hangs on both of them but on one it has worked a couple of times and then I try again and it hangs with nothing apparently different than the time it worked.

I tried using the AddFiles method and doing each folder within the project to its own zip file. When I do this it works fine on all but these 2 projects. It seems to work on all sub folders of the troublesome project but when it tries to zip the main project folder it hangs every time.

I have looked at the files in the folder and there was a .rar file and a couple of uninstall related files there. I removed these hoping that maybe that was the issue but still have the same issue. All of the files have the normal attribute at this point and the total is 142 files 6.2 mb largest file being 1.2 mb, source files, exe files MDB and a couple of icons. Nothing that I would think should be an issue.

If I try to zip the folder with WinRar it works just fine but when I try to do the parent folder using the iconic.zip class it creates a .tmp file in the target directory that seems to be about the right size and then that is as far as it goes. If I pause the application it is setting there on the save line waiting for it to finish.

Any idea what I should check to overcome this issue?

February 1st, 2013, 03:24 AM

BioPhysEngr

Re: Issue with DotNetZip ionic.zip class hanging on save

First (probably stupid) idea: Could it be choking on spaces or special characters (parenthesis?) that are unique to those folders?

If you aren't absolutely committed to using the ionic library, I would recommend SharpZipLib (http://www.icsharpcode.net/opensource/sharpziplib/). I looked at both ionic and SharpZipLib a few months ago as part of a project and decided SharpZipLib was somewhat easier to work with. (And, as a minor benefit, the devs are extremely friendly and responsive). [EDIT: Not to imply the guys who wrote ionic aren't]

February 1st, 2013, 10:32 AM

DataMiser

Re: Issue with DotNetZip ionic.zip class hanging on save

Quote:

Originally Posted by BioPhysEngr

First (probably stupid) idea: Could it be choking on spaces or special characters (parenthesis?) that are unique to those folders?

Good thought but no spaces or special characters in any of the fielnames

before the AddDirectory() call and it managed to create all of the zip files for all of the projects. So I think that should do it. I did have some display issues along the way but that is a different issue that I should be able to work out pretty quickly.

Quote:

If you aren't absolutely committed to using the ionic library, I would recommend SharpZipLib (http://www.icsharpcode.net/opensource/sharpziplib/). I looked at both ionic and SharpZipLib a few months ago as part of a project and decided SharpZipLib was somewhat easier to work with. (And, as a minor benefit, the devs are extremely friendly and responsive). [EDIT: Not to imply the guys who wrote ionic aren't]