• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 607
  • Last Modified:

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()
0
roddios
Asked:
roddios
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
Question #1:  Does 'astrFileNames' return anything (Length > 0)?

Bob
0
 
roddiosAuthor Commented:
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
0
 
Bob LearnedCommented:
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.

Bob
0
 
roddiosAuthor Commented:
thanks for your time anyway

cheers
Rod
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now