473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing a file to output using Response.BinaryWrite?

I have a stream of bytes (making up a large file) coming from
somewhere, and need to send it to the user. I can't send it to
Response.OutputStream because this is read only, and storing the
entire file in memory and then outputting that isn't really an option
as the files are in excess of 200mb each. I am considering having a
loop, and reading the stream and creating a buffer byte array every
100kb or so, and then using Response.BinaryWrite to send this to the
user - will this work if I set buffer to false and set the headers/
contenttype correctly (IE: User gets file download box, and as they
download my loop runs sending the bytes through), or will the user
just see junk?

Oct 2 '07 #1
1 2069
your approach is correct.

-- bruce (sqlwork.com)

Chris Ashley wrote:
I have a stream of bytes (making up a large file) coming from
somewhere, and need to send it to the user. I can't send it to
Response.OutputStream because this is read only, and storing the
entire file in memory and then outputting that isn't really an option
as the files are in excess of 200mb each. I am considering having a
loop, and reading the stream and creating a buffer byte array every
100kb or so, and then using Response.BinaryWrite to send this to the
user - will this work if I set buffer to false and set the headers/
contenttype correctly (IE: User gets file download box, and as they
download my loop runs sending the bytes through), or will the user
just see junk?
Oct 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Don Grover | last post by:
How can I force a download of a csv file by user clicking on hyperlink. Don
3
by: Olav Tollefsen | last post by:
I'm using the following code to create an Xml document to be saved by the browser (IE): MemoryStream stream = new MemoryStream(); OrderManager.ExportToXml(stream); // Creates...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response ...
4
by: David | last post by:
Hi all, I am trying to write a class file, but am not quite sure what I am doing. What I want to do is from within an ASP page is to call a class. The class must then create a text file...
3
by: Cathryn Johns | last post by:
Hi I'm trying to download some content as a file to the client. My code behind looks like this: private void DownloadFile(byte contents) { Response.ContentType = "text/csv";...
2
by: ATS | last post by:
HOWTO Override ASP's Response output for 2003/IIS. Please help, I want to have an ASP page write back EVERYTHING to the ASP Response. That includes HTTP Headers. I want my ASP to look...
5
by: twiggy182 | last post by:
Hi, I really need you help because I'm not very familliar with ASP and I could not find any solution to my problem. To put you in situation, I have a CGI to which I send a file name, and that...
7
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm building an ASP.NET site which is hosted on a remote server. When I try to create a new file using StreamWriter I must specify the drive location where the file will be saved. I don't...
14
by: S N | last post by:
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client. Kindly indicate the maximum size of the file that can be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.