VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Write Zip to ASP.NET Response

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

Demonstrates how to write a .zip file to the ASP.NET Response object in VB.NET. The "Zip" variable is a Chilkat.Zip object. It could have loaded a .zip file, or created a .zip dynamically in memory via AppendData or AppendString/AppendAnsi methods. Regardless, the point of this example is to show how to send the zip file to the ASP.NET response. The Zip.WriteToMemory method writes the zip file to an in-memory byte array, and this is written to the Response via BinaryWrite.

   'Return atached file
    Dim Data As Byte()
    Data = Zip.WriteToMemory

    Response.Clear()
    Response.ContentType = "application/octet-stream"
    Response.AddHeader("Content-Length",Data.Length.ToString())
    Response.AddHeader("Content-Disposition", _
                       "attachment; filename=""" & Zip.FileName & """")
    Response.Flush()
    Response.BinaryWrite(Data)

'The reason Im using "application/octet-stream" is to force
'the Open, Save, Cancel dialog box to popup. For the above code to work 
'correctly, Ive had to include the following override:

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

	'Do nothing... I've added this to prevent the normal rendering of pages from
	'happening. Even though I was clearing the content from the render stream,
	'it was STILL being sent downstream and FUBARing my returned files.

End Sub





 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser