' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO
Imports ICSharpCode.SharpZipLib.Zip

Class TestClass
    Public Const N As Integer = 100

    Public Shared Sub Main(ByVal args As String())
        Dim zos As ZipOutputStream = New ZipOutputStream(New FileStream("C:\Test.zip", FileMode.Create))
        Dim i As Integer = 0
        While i < N
            Dim fs As FileStream = New FileStream("C:\Test.doc", FileMode.Open)
            Dim b(fs.Length) As Byte
            fs.Read(b, 0, b.Length)
            fs.Close
            Dim ze As ZipEntry = New ZipEntry("Test" & i & ".doc")
            zos.PutNextEntry(ze)
            zos.Write(b, 0, b.Length)
            System.Math.Min(System.Threading.Interlocked.Increment(i),i-1)
        End While
        zos.Finish
        zos.Close
    End Sub
End Class 
