Was able to solve my problem and including the code for others. Hopefully you find it helpful. What I did was pass the filename into a page called DownloadFile.aspx.
Dim
filename
As
String
= MapPath(
"~"
) &
"Repository\FTPCloud\" & Request("
file").ToString()
Dim
extension
As
String
= Path.GetExtension(filename)
Dim
file
As
System.IO.FileInfo =
New
System.IO.FileInfo(filename)
'-- if the file exists on the server
If
file.Exists
Then
'set appropriate headers
Response.Clear()
Select
Case
extension
Case
".txt"
Response.ContentType =
"text/plain"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".txt")
Case
".xls"
Response.ContentType =
"application/vnd.ms-excel"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".xls")
Case
".xlsx"
Response.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".xlsx")
Case
".pdf"
Response.ContentType =
"application/pdf"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".pdf")
Case
".zip"
Response.ContentType =
"application/zip"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".zip")
Case
".doc"
Response.ContentType =
"application/msword"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".doc")
Case
".docx"
Response.ContentType =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
Response.AddHeader(
"content-disposition"
, (Convert.ToString(
"attachment; filename="
) & Path.GetFileName(filename)))
' + ".docx")
End
Select
'Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
'Response.AddHeader("Content-Length", file.Length.ToString())
'Response.ContentType = "application/octet-stream"
Response.WriteFile(filename)
Response.
End
()
'if file does not exist
Else
Response.Write(
"This file does not exist."
)
End
If
'nothing in the URL as HTTP GET