Hola, como estas recuperando el archivo. Lo muestras en un gridview o como? Si es asi esta seria una forma
Código ASP:
Ver originalDim ib As ImageButton = DirectCast(sender, ImageButton)
Dim index As Integer = Convert.ToInt32(ib.CommandArgument)
Dim lb As LinkButton = DirectCast(gvwFiles.Rows(index).FindControl("gvlnkName"), LinkButton)
Session("DownloadFileName") = lb.CommandArgument
Response.Redirect("~/Download/Download.aspx")
Y la pagina Download.aspx, conteniendo esto
Código ASP:
Ver originalProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
' retrieve the path of the file to download, and create
' a FileInfo object to read its properties
' string path = Server.MapPath(Request.QueryString["File"]);
Dim path As String = Session("DownloadFileName").ToString()
Session("DownloadFileName") = Nothing
Dim file As New System.IO.FileInfo(path)
' clear the current output content from the buffer
Response.Clear()
' add the header that specifies the default filename for the Download/SaveAs dialog
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
' add the header that specifies the file size, so that the browser
' can show the download progress
Response.AddHeader("Content-Length", file.Length.ToString())
' specify that the response is a stream that cannot be read by the
' client and must be downloaded
Response.ContentType = "application/octet-stream"
' send the file stream to the client
Response.WriteFile(file.FullName)
' stop the execution of this page
Response.[End]()
Catch generatedExceptionName As Exception
Response.Write("<p style=""color:red;font-size=20px;font-weight:bold"">Invalid download session</p>")
End Try
Igualmente puedes mapear el archivo directamente
con un
y enviarlo a descargar