470,647 Members | 1,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

generate custom file for download

I need a way of creating a custom file which can be downloaded by a user.
The file needs to be customized pre user (ie serial number built in).
Creating the file is no problem. The problem is how can several files be
created at the same time (ie several users logged in to the web site at once
wanting to download their file). A temporaty file can easily be created,
but how does the file get deleted after the user downloads it (or aborts the
download), and how can the file name be the same for all users?
Nov 18 '05 #1
3 1415
Do you need to keep a copy of the file? If it is generated "on the fly" and
they download it at the time they request it, can you just keep the file as
a fileStream?

I do something similar. When they request the file, I'll pop-up another
..aspx page with a parameter or session var that has the information on what
to create in the file. The new .aspx page will clear the output, and stream
out the file. This will prompt the user to download the file without
actually showing another window to open and not losing the page they are on.

Would something like that work?

-Darrin

"Paul" <cg***@hotmail.com> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
I need a way of creating a custom file which can be downloaded by a user.
The file needs to be customized pre user (ie serial number built in).
Creating the file is no problem. The problem is how can several files be
created at the same time (ie several users logged in to the web site at
once wanting to download their file). A temporaty file can easily be
created, but how does the file get deleted after the user downloads it (or
aborts the download), and how can the file name be the same for all users?

Nov 18 '05 #2
Yes, it is created "On the fly", I don't need to keep a copy.

Sounds like your solution would work. Do you have sample code?

thanks for your reply
"Darrin J Olson" <da************@sio.midco.net> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
Do you need to keep a copy of the file? If it is generated "on the fly"
and they download it at the time they request it, can you just keep the
file as a fileStream?

I do something similar. When they request the file, I'll pop-up another
.aspx page with a parameter or session var that has the information on
what to create in the file. The new .aspx page will clear the output, and
stream out the file. This will prompt the user to download the file
without actually showing another window to open and not losing the page
they are on.

Would something like that work?

-Darrin

"Paul" <cg***@hotmail.com> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
I need a way of creating a custom file which can be downloaded by a user.
The file needs to be customized pre user (ie serial number built in).
Creating the file is no problem. The problem is how can several files be
created at the same time (ie several users logged in to the web site at
once wanting to download their file). A temporaty file can easily be
created, but how does the file get deleted after the user downloads it (or
aborts the download), and how can the file name be the same for all users?


Nov 18 '05 #3
Here is an example of clearing the output and sending your stream. In this
example I'm sending PDF files created on the fly.

Stream _strm = null;

//Insert code here to set _strm to some inherited stream object.

Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline;
filename=Estimate.pdf");

byte[] _buffer = new byte[_strm.Length];
_strm.Read(_buffer, 0, int.Parse(_strm.Length.ToString()));
Response.BinaryWrite(_buffer);
Response.Flush();
Hope this helps!
-Darrin
"Paul" <cg***@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
Yes, it is created "On the fly", I don't need to keep a copy.

Sounds like your solution would work. Do you have sample code?

thanks for your reply
"Darrin J Olson" <da************@sio.midco.net> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
Do you need to keep a copy of the file? If it is generated "on the fly"
and they download it at the time they request it, can you just keep the
file as a fileStream?

I do something similar. When they request the file, I'll pop-up another
.aspx page with a parameter or session var that has the information on
what to create in the file. The new .aspx page will clear the output, and
stream out the file. This will prompt the user to download the file
without actually showing another window to open and not losing the page
they are on.

Would something like that work?

-Darrin

"Paul" <cg***@hotmail.com> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
I need a way of creating a custom file which can be downloaded by a user.
The file needs to be customized pre user (ie serial number built in).
Creating the file is no problem. The problem is how can several files be
created at the same time (ie several users logged in to the web site at
once wanting to download their file). A temporaty file can easily be
created, but how does the file get deleted after the user downloads it
(or aborts the download), and how can the file name be the same for all
users?



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by James Coe | last post: by
3 posts views Thread by Dennis M | last post: by
8 posts views Thread by Phil Lee | last post: by
1 post views Thread by John Q. Adams | last post: by
4 posts views Thread by Andrew Taylor | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.