CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2002
    Location
    ireland
    Posts
    291

    Zip a directory or unzip a zipfile and edit it's contents

    How can I zip the contents of a directory programmatically?

    How can I unzip and existing zipfile and edit it's contents and then rezip to the same file?

    GZipStream zips and unzips files, is there some way to manipulate this to zip a directory (recursively)?

    Is there another .NET utility out there?

    Thanks.

  2. #2
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: Zip a directory or unzip a zipfile and edit it's contents

    Maybe you should use this library.
    Useful or not? Rate my posting. Thanks.

  3. #3
    Join Date
    Aug 2002
    Location
    ireland
    Posts
    291

    Re: Zip a directory or unzip a zipfile and edit it's contents

    Thanks.
    You're actually the second person that has pointed me to that.
    I'd prefer to stay away from 3rd party software if possible, for now anyway.

    I guess .NET 2.0 has nothing which can do this for me, strange

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    Re: Zip a directory or unzip a zipfile and edit it's contents

    well .NET 2.0 doesn't come with built-in support for compression and uncompression.
    you would want to include 3'rd party library. if you don't want to include 3'rd party programs then
    1) create your own simple compression algorithm as per mentioned in data structures book
    or
    2) take open source sample and try to use as a class.
    (understanding that first)

    I guess it shouldn't be that hard too...

    hope this helps
    Paresh
    - Software Architect

  5. #5
    Join Date
    Jun 2005
    Posts
    160

    Re: Zip a directory or unzip a zipfile and edit it's contents

    http://www.codeproject.com/csharp/VmEasyZipUnZip.asp


    I think this is easy way to handle zip and unzip operations...

    But you need to install microsoft visual j#.net redistributable package.......

  6. #6
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: Zip a directory or unzip a zipfile and edit it's contents

    Quote Originally Posted by pareshgh
    2) take open source sample and try to use as a class.
    (understanding that first)
    By doing this it is needed to watch the licence of the open source sample. Otherwise you can run into heavy licence violations. For example you can not do that with the library I posted above because it is published under the GPL, so you can not compile the related classes in your software without distributing your software under the same licence.

    It is better to link against the binary because this is unprohibited by a licence exception for that library.

    But in general it is possible to do as pareshgh said if the author permits the usage of the sample code.
    Useful or not? Rate my posting. Thanks.

  7. #7
    Join Date
    Aug 2002
    Location
    ireland
    Posts
    291

    Re: Zip a directory or unzip a zipfile and edit it's contents

    Thanks.
    I haven't time to start developing my own version right now.. as much as I'd love to.

    A workaround I think I've found is to do the Zipping in an MsBuild task instead of in the code.
    And to my surprise MS haven't developed a good implementation of this, their implementation is limited, there is however another opensource implementation out there which may help me
    http://msbuildtasks.tigris.org

    Their implementation should allow me to zip what files I want into a zip file at build time.

    Thanks for the help.

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