CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    [RESOLVED] Issue with DotNetZip ionic.zip class hanging on save

    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?
    Last edited by DataMiser; January 31st, 2013 at 10:49 PM. Reason: typos
    Always use [code][/code] tags when posting code.

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    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?

    This StackOverflow post suggests it could be some sort of buffer related deadlock bug: http://stackoverflow.com/questions/4...o-memorystream

    See also: http://dotnetzip.codeplex.com/workitem/15126

    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]
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

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

    Quote Originally Posted by BioPhysEngr View Post
    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

    This StackOverflow post suggests it could be some sort of buffer related deadlock bug: http://stackoverflow.com/questions/4...o-memorystream
    Thanks, not sure that one applies, the user says if he saves it to file it works ok

    This one seems to have given me a solution. I added the line
    Code:
    ZP1.ParallelDeflateThreshold = -1
    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.

    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]
    I'll check it out and see how it does.

    Thanks for the info, I think I can put this one to bed now
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured