Author: CapedCoder | Posted on: 10/29/2009 12:22:20 AM | Views : 285

Here's the code:
Dim fs As System.IO.FileStream = Nothing
If Server.MachineName = "JNICOMPAQ" Then
fs = System.IO.File.Open(Server.MapPath("~/kidsid/" & strFileName & ".txt"), System.IO.FileMode.Open)
Else
fs = System.IO.File.Open(Server.MapPath("kidsid/" & strFileName & ".txt"), System.IO.FileMode.Open)
End If
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, fs.Length)
fs.Close()
With Response
.Clear()
.AddHeader("Content-disposition", "attachment;filename=" & strFriendlyName)
.ContentType = "text/plain"
.BinaryWrite(btFile)
.End()
End With
 
I've tried various MIME types as well as using the file name and use FileWrite.  The Save File dialog appears.  If I choose Open, the contents appear as they should in the text fil ...

Go to the complete details ...