Creating a downloadable file on the fly

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
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.
 
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?
 
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
 
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.
 
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
 
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
 
Back
Top