Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Write Zip to ASP.NET Response
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.