VC Component source - 43 Kb
VB Component source - 6 Kb
Example ASP script - 1 Kb
This article is about direct file downloading through a COM component. It uses the
IResponse interface to send a file directly to the client browser.
With this approach you can protect your files from being downloaded by an unauthorized
To send the file to the client you need to register this kind of file within the IIS
MIME types. To do it go to the ISS administration and under the HTTP Header add this kind
of file. In the sample a zip file is used, so the MIME type is:
To send a file to the browser you must set the
TRUE and the
ContentType to the file type. After this you
send the data using the
Response object through the
To accomplish this task a component was developed:
interface used is called
IBinaryRead. These are its methods:
||This method returns the content of the file as an VARIANT (SAFEARRAY)
||This method reads the file and send it using the Response object. It returns the operation result
If you want to download a custom file type, you must register it in the client machine too.
An example of using the
FileTransfer object follows:
Dim saBinFile Dim bDownloadStatus
Set objBinaryRead = CreateObject("FileTransfer.BinaryRead")
Response.Buffer = true
Response.ContentType = "application/x-zip-compressed"
bDownloadStatus = objBinaryRead.ResponseBinaryWrite("c:\temp\test.zip", Response)
Set objBinaryRead = nothing
XicoLoko is a brazilian developer based in Switzerland.