Hello-
for some reason, my file download is not working correctly- I'm creating folders dynamically on the server based on the ID of the record, that is fine, I have a button with the following code:
The file downloads, but when I open it (say MS Word) It asks for the stylesheets and then-- I click no, then it actually loads the page, not the file-- what is wrong?
Thanks!
for some reason, my file download is not working correctly- I'm creating folders dynamically on the server based on the ID of the record, that is fine, I have a button with the following code:
Code:
FuelSurchargeID = Request.QueryString("FuelSurchargeID").ToString
Dim root As String = "D:\Staging\secure\memnet\fuel_surcharge\attachments\" & FuelSurchargeID & "\"
Dim files() As String = Directory.GetFiles(root)
Dim sb As New StringBuilder(2048)
Dim f As String
Dim type As String = ""
For Each f In files
Dim filename As String = Path.GetFileName(f)
Dim ext = Path.GetExtension(f)
Response.Clear()
Response.ContentType = "application/octet-stream"
Select Case ext
Case ".htm", ".html"
type = "text/HTML"
Case ".txt"
type = "text/plain"
Case ".pdf"
type = "Applicaton/pdf"
Case ".doc", ".rtf"
type = "Application/msword"
Case ".csv", ".xls"
type = "Application/x-msexcel"
Case Else
type = "text/plain"
End Select
Response.AddHeader("Content-Disposition", _
"attachment; filename=""" + filename + """")
If type <> "" Then
Response.ContentType = type
End If
Response.Flush()
Next
The file downloads, but when I open it (say MS Word) It asks for the stylesheets and then-- I click no, then it actually loads the page, not the file-- what is wrong?
Thanks!