Color coat your code like below at: ASP.NET Resources
Download Large Binary Files via ASP
  • First get file size.
  • Create the file pointer.
  • Load and write binary chunks.
  • /* Download Large Binary Files via ASP:  
          Take large binary files and send them down through the a browser.
    
     Copyright:
          2007-2008, Karland International (www.karland.com/www.chizl.com)
    
     Permission:
          Permission to use, copy, modify, distribute and sell this software and its 
          documentation for any purpose is hereby granted without fee, provided that the 
          above copyright notice appears in all copies and that both that copyright notice 
          and this permission notice appear in supporting documentation. Karland International 
          makes no representations about the suitability of this software for any purpose. 
          It is provided "as is" without express or implied warranty.
    */
    
    	Response.Buffer = True
      
    	Const adTypeBinary = 1
    
    	Dim objFile
    	Dim iFileSize, iChunkSize, iFileLeft
    	Dim strFilePath
    	
    	strFilePath = "C:\ExcelFiles\Excel1.xls" 'This is the path to the file on disk. 
    
    	'Set the content type to the specific type that you are sending.
    
    	Set objFile = objFSO.GetFile(strFilePath)
    	'get file size
    
    	iFileSize = objFile.Size
    	iFileLeft = iFileSize
    	
    	'set file name
    
    	Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
    	'set file size
    
    	Response.AddHeader "Content-Length", iFileSize
    	'set file type
    
    	Response.ContentType = "application/x-msexcel"
    	
    	Set objStream = Server.CreateObject("ADODB.Stream")
    	objStream.Open
    	objStream.Type = adTypeBinary
    	
    	objStream.LoadFromFile strFilePath
    	
    	'do until end of stream or client disconnects
    
    	Do While Not objStream.EOS Or Not Response.IsClientConnected
    		'if the chunk size is larger than the size of data left to be sent, shrink the chunk size
    
    		If iChunkSize > iFileLeft Then iChunkSize = iFileLeft
    		
    		'write to browser
    
    		Response.BinaryWrite(objStream.Read(iChunkSize))
    		'flush the response buffer or it will not go past 4MB
    
    		Response.Flush
    		'figure out whats left of the file
    
    		iFileLeft = iFileLeft - iChunkSize
    	Loop
    	
    	'clean up
    
    	objStream.Close
    	Set objStream = Nothing
    	Set objFile = Nothing