Here is some sample code that will download a text file named download.txt
with some text and the date/time appended to the end. To download another
file type you would do the same thing, just change the Response.ContentType
and Response.WriteFile lines, and possibly add or remove any Response.Write
or Response.WriteFile lines. One thing that you can also do is not save the
file at all, and just use a bunch of Response.Write lines to dynamically
create something like a tab delimited data file or a schedule or reciept or
whatever, using only Response.Write saves you the trouble of saving a
temporary file every time someone downloads something unique to their
situation. I think you probably have the basic idea, if you have any
problems, let me know.
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDownload.Click
Response.ClearContent()
Response.ContentType = "text/plain"
Response.AddHeader("content-disposition",
"attachment;filename=download.txt")
Response.WriteFile(Server.MapPath("download.txt"))
Response.Write("This is a test download text file" & ControlChars.NewLine)
Response.Write(Date.Now.ToLongDateString() & " " &
Date.Now.ToLongTimeString())
Response.End()
End Sub
Good Luck!