SharpZipLib I'm getting an empty folder as a result when compressing a folder using the SharpZipLib library
Posted on 2007-10-17
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)