Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/08/2010, 13:50
Avatar de jaullo
jaullo
 
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: Descarga de archivo

Hola, como estas recuperando el archivo. Lo muestras en un gridview o como? Si es asi esta seria una forma

Código ASP:
Ver original
  1. Dim ib As ImageButton = DirectCast(sender, ImageButton)
  2.         Dim index As Integer = Convert.ToInt32(ib.CommandArgument)
  3.         Dim lb As LinkButton = DirectCast(gvwFiles.Rows(index).FindControl("gvlnkName"), LinkButton)
  4.         Session("DownloadFileName") = lb.CommandArgument
  5.         Response.Redirect("~/Download/Download.aspx")

Y la pagina Download.aspx, conteniendo esto

Código ASP:
Ver original
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         Try
  3.             ' retrieve the path of the file to download, and create
  4.             ' a FileInfo object to read its properties
  5.             ' string path = Server.MapPath(Request.QueryString["File"]);
  6.             Dim path As String = Session("DownloadFileName").ToString()
  7.             Session("DownloadFileName") = Nothing
  8.  
  9.             Dim file As New System.IO.FileInfo(path)
  10.  
  11.             ' clear the current output content from the buffer
  12.             Response.Clear()
  13.  
  14.             ' add the header that specifies the default filename for the Download/SaveAs dialog
  15.             Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
  16.             ' add the header that specifies the file size, so that the browser
  17.             ' can show the download progress
  18.             Response.AddHeader("Content-Length", file.Length.ToString())
  19.             ' specify that the response is a stream that cannot be read by the
  20.             ' client and must be downloaded
  21.             Response.ContentType = "application/octet-stream"
  22.             ' send the file stream to the client
  23.             Response.WriteFile(file.FullName)
  24.             ' stop the execution of this page
  25.             Response.[End]()
  26.  
  27.         Catch generatedExceptionName As Exception
  28.             Response.Write("<p style=""color:red;font-size=20px;font-weight:bold"">Invalid download session</p>")
  29.         End Try
Igualmente puedes mapear el archivo directamente
con un

Código ASP:
Ver original
  1. Server.mappath("/archivo.doc")
y enviarlo a descargar
__________________
http://geekswithblogs.net/jaullo/Default.aspx
Si te he ayudado regalame Karma positivo!!!