Creating a downloadable file on the fly

M

Maziar Aflatoun

Hi everyone,

I like to export some data from the database and allow my users to store
this file to their harddrive as a .txt file. Does anyone know how I would
go about doing that? (without creating the actual physical text file on my
local drive first).


Thank you
Maziar A.
 
M

Maziar Aflatoun

Maybe I did not explain myself right. I don't want to upload files to the
server. I want to allow the user (person browsing my website) to download a
dynamically created text file without actually creating the file on the
local machine. So the user would see something like 'Save as' where then
they can store the file to their local hard-drive.

Any idea?
 
J

Jerry Boone

I hear what you are asking, but... just in case someone doesn't come up with
a good idea, I will let you know what I do.

I make a temp folder on the website. When a user clicks on a link to "Make"
a file (I build pdf's with Crystal Reports), I create a folder and name it
with the Session.SessionID value. Then I place the file in that folder and
the next page displays a link to the file.

When the Session expires, I delete the folder.

Both events for creating and destroying the folders are handled in
global.asax.vb using Session_Start and Session_End

This sounds like more work than something simple that would stream the data,
but I haven't figured that one out yet either...

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access
 
K

Kevin Spencer

The tricky part is getting a FileStream to work with. When the file is
uploaded, it is not in a stream format, but in a text format (encoded
binary). I'm not sure how you would do it offhand, but you would have to
convert it to a FileStream to output it to the Response.OutputStream.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
J

Jerry Boone

I see - thanks, not sure if I can get a stream my stuff (will look into it
next time I'm there) but maybe Maziar can... :)

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access
 
J

JDModev

I'm trying to get my code to do the same thing... (creating a folder on
session_start and deleting it on session_end)

My problem is I can't get it to work, the treads just time out on the
<code> Dim di As New System.IO.DirectoryInfo(Server.MapPath("images/" &
Session.SessionID & "/")) </code> line. Could you post your code so I
can see what I'm doing wrong?

Thanks,
Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top