VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
PFX
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Byte Array
VB.NET FTPS
System.IO

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

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
    Response.Clear()
    Response.ContentType = "application/octet-stream"
    Response.AddHeader("Content-Disposition", _
                       "attachment; filename=""" & Zip.FileName & """")
    Response.Flush()
    Data = Zip.WriteToMemory
    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-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser