Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to binary stream a file to user

Posted on 2006-05-21
Medium Priority
Last Modified: 2010-04-16

I want to binary stream a file i.e. temp.zip to a visitor when he clicks on a link so that "save file as..." appears and allows him to save the file. I need the stream because the file will be located outside the wwwroot. Would it be possible to send me a sample code for this?

Question by:infodigger
1 Comment
LVL 20

Accepted Solution

TheAvenger earned 2000 total points
ID: 16732342
You can create a page, set its content type to the appropriate file type, write the file in the reponse stream and finally end the response. An example would be:

this.Response.ContentType = contentType;
this.Response.OutputStream.Write(file, 0, file.Length);

The ContentType is different for every file type and you can find it in google.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question