JabbaTheNut
Programmer
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!
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!