Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Downloading Dynamically Generated Text File

Status
Not open for further replies.

JabbaTheNut

Programmer
Jul 29, 2002
176
US
I want the client to be able to download a text file that is dynamically generated (i.e., not stored on the server's hard drive).

I have successfully used the following code for a non-dynamic text file that is stored on the server's hard drive:


Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click

Dim fullpath As String = "c:\testdoc.txt"
Dim fname As String = "testdoc.txt"
Response.Clear()
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", _
"attachment; filename=""" & fullpath & """")
Response.Flush()
Response.WriteFile(fname)

End Sub



How can I modify this for a dynamically generated text file?

For example...

Assume that I want to generate a text file (for immediate download by the client) that contains the phrase "Hello World!". Without saving the file to the hard drive and then sending it to the client for download (as described in the code above) and then deleting the file from the hard drive afterward, how should the code be written?



Game Over, Man!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top