Link to home
Start Free TrialLog in
Avatar of roddios
roddios

asked on

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

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

Thanks
Rod


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
      s.SetLevel(5)
      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.PutNextEntry(objZipEntry)
        s.Write(abyBuffer, 0, abyBuffer.Length)
        strmFile.Close()
      Next
      s.Finish()
      s.Close()
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Question #1:  Does 'astrFileNames' return anything (Length > 0)?

Bob
Avatar of roddios
roddios

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roddios

ASKER

thanks for your time anyway

cheers
Rod