Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Downloading files

0 views
Skip to first unread message

tshad

unread,
Mar 7, 2006, 10:19:58 PM3/7/06
to
I have some code to allow me to send text files to my user. I am not
allowing them to view my directory. I am just downloading a file they
previously requested, which works some of the time.

Dim fs As FileStream
Dim strContentType As String
Dim strPath = "C:\My External\File Path\"
Dim strFileName As String = "TomsTest.txt"
fs = File.Open(strPath & strFileName, FileMode.Open)
Dim bytBytes(fs.Length) As Byte
fs.Read(bytBytes, 0, fs.Length)
fs.Close()
Response.AddHeader("Content-disposition", _
"attachment; filename=" & strFileName)
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(bytBytes)
Response.End()

If I run this on an XP and the user has Automatic downloads of files
disabled, the user will get a blank page with all the text displaying on it.

If it is enabled, I get the Save As prompt and allows the user to save the
file.

This can be confusing to the user. Is there a way for me to know if the
user will have a problem with the download?

This is not an automatic download, the user is actually pushing a button
saying he wants to download the file.

Thanks,

Tom


Kevin Spencer

unread,
Mar 8, 2006, 6:34:50 AM3/8/06
to
Your bes bet would be to write a custom HttpHandler for delivering .txt
files.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.

"tshad" <tschei...@ftsolutions.com> wrote in message
news:uXK8u8lQ...@tk2msftngp13.phx.gbl...

0 new messages