<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

' Read the file we are going to compress into a FileStream
Dim filename As String = Server.MapPath("TextFile.txt")

        Dim infile As System.IO.FileStream = System.IO.File.OpenRead(filename)
        Dim buffer(infile.Length) As Byte
        infile.Read(buffer, 0, buffer.Length)
        infile.Close()

        ' Create the output file
        Dim outfile As System.IO.FileStream = _
            System.IO.File.Create(System.IO.Path.ChangeExtension(filename, "zip"))

        ' Compress the input stream and write it to the output FileStream
        Dim gzipStream As New System.IO.Compression.GZipStream( _
            outfile, System.IO.Compression.CompressionMode.Compress)
        gzipStream.Write(buffer, 0, buffer.Length)
        gzipStream.Close()

End Sub
</script>