SharpZipLib I'm getting an empty folder as a result when compressing a folder using the SharpZipLib library

Posted on 2007-10-17
Medium Priority
Last Modified: 2012-08-14
I pretty much uses the code provided in the example to create a zip file, but the output file is empty and has no content. I'm using .NET 1.1, Windows XP SP2  and Visual Studio 2003.
I have also compiled the sample project that came with the library and again the output zip file is empty.

Has anyone run into this problem and knows what to do to fix it


Dim dir As String
    dir = "E:\wwwroot\test"
    Dim astrFileNames() As String = Directory.GetFiles(dir)
    Dim targetName As String = "E:\wwwroot\backup\test.zip"
    Dim s As Zip.ZipOutputStream
    Dim objZipEntry As Zip.ZipEntry

      s = New Zip.ZipOutputStream(File.Create(targetName))
      REM Compression Level: 0-9
      REM 0: no(Compression)
      REM 9: maximum compression
      Dim strFile As String
      For Each strFile In astrFileNames
        Dim strmFile As FileStream = File.OpenRead(strFile)
        Dim abyBuffer(strmFile.Length - 1) As Byte
        strmFile.Read(abyBuffer, 0, abyBuffer.Length)
        objZipEntry = New Zip.ZipEntry(strFile)
        objZipEntry.DateTime = DateTime.Now
        objZipEntry.Size = strmFile.Length
        s.Write(abyBuffer, 0, abyBuffer.Length)
Question by:roddios
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 20095305
Question #1:  Does 'astrFileNames' return anything (Length > 0)?


Author Comment

ID: 20095760
Yes it does
as the matter of fact i don't think it's a problem with the code.
I have downloaded the evaluation copy of winzip and i can unzip my folder and see all the files... weirrrrrrrrd but the version I was using was the free one that comes originally with Windows and was showing an empty folder
LVL 96

Accepted Solution

Bob Learned earned 1000 total points
ID: 20095775
It didn't look like you had anything wrong with the code, so I was thinking that it had to be something that I couldn't see.


Author Comment

ID: 20096458
thanks for your time anyway


Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question