T
tshad
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
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