Correciones de descarga de archivos

This commit is contained in:
2020-05-12 01:21:06 -07:00
parent d36ed8b48e
commit 5e14074189
5 changed files with 31 additions and 3 deletions

View File

@@ -130,6 +130,30 @@ Partial Class PopUpVerFactura
Dim Path As String = String.Format("{0}Ventas\{1}\{2}", UsuarioActual.Empresa.Ruta, Request("RFC"), Request("FileV"))
Dim Archivo As New System.IO.FileInfo(Path)
If Archivo.Exists Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = If(IO.Path.GetExtension(Archivo.Name) = "xml", "application/xml", "application/pdf")
HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name))
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
HttpContext.Current.Response.TransmitFile(Path)
'HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End If
Archivo = Nothing
ElseIf Request("File") IsNot Nothing AndAlso Request("TipoDocto") IsNot Nothing AndAlso Request("TipoArchivo") IsNot Nothing Then
Dim Path As String = "" ' String.Format("{0}Ventas\{1}\{2}", UsuarioActual.Empresa.Ruta, Request("RFC"), Request("FileV"))
Select Case Request("TipoArchivo")
Case "PDF"
Path = String.Format("{0}PDF\{1}\{2}", UsuarioActual.Empresa.Ruta, Request("TipoDocto"), Request("File"))
Case "XML"
Path = String.Format("{0}XML\{1}\{2}", UsuarioActual.Empresa.Ruta, Request("TipoDocto"), Request("File"))
End Select
Dim Archivo As New System.IO.FileInfo(Path)
If Archivo.Exists Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()