Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/04/2004, 08:53
Avatar de RootK
RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años, 1 mes
Puntos: 50
Te paso una funcion (espero que les sirva a alguien mas )para que tu eligas si quieres descargarlo o que se muestre en el browser...

Voy a hacer el ejemplo con archivos de excel,txt y de word.

Es importante que hagan referencia al namespace System.IO


VB.Net

Cita:
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As Boolean)
Dim path As Path
Dim fullpath = path.GetFullPath(fname)
Dim name = path.GetFileName(fullpath)
Dim ext = path.GetExtension(fullpath)
Dim type As String = ""

If Not IsDBNull(ext) Then
ext = LCase(ext)
End If

Select Case ext
Case ".txt"
type = "text/plain"
Case ".doc", ".rtf"
type = "Application/msword"
Case ".csv", ".xls"
type = "Application/x-msexcel"
Case Else
type = "text/plain"
End Select

If (forceDownload) Then
Response.AppendHeader("content-disposition", _
"attachment; filename=" + name)
End If
If type <> "" Then
Response.ContentType = type
End If

Response.WriteFile(fullpath)
Response.End()

End Sub
Y para llamarlo:
Cita:
DownloadFile("c:\miarchivo.doc", True)
Donde True indica que lo pueda guardar y false que lo descarge sin que salga la ventana de confirmación.

Espero les sea útil... (éste ejemplo lo hice con IE y me funciona sibn problemas, pero no se si tambien funcione en otros browsers.

Saludos
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net