33 lines
1.2 KiB
VB.net
33 lines
1.2 KiB
VB.net
|
|
Partial Class Metronic_SigAyuda
|
|
Inherits System.Web.UI.Page
|
|
|
|
Protected Sub btnDownload_Click(sender As Object, e As EventArgs)
|
|
Try
|
|
Dim docto As String = TxtDocto.Text.Replace("/", "\")
|
|
|
|
Dim path As String = $"{AppDomain.CurrentDomain.BaseDirectory}{docto}"
|
|
|
|
|
|
Dim file As New System.IO.FileInfo(path)
|
|
Dim mimeType As String = "text/plain"
|
|
Try
|
|
mimeType = MimeMapping.GetMimeMapping(path)
|
|
Catch ex As Exception
|
|
End Try
|
|
'Response.Write(path)
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}")
|
|
Response.AddHeader("Content-Length", file.Length.ToString())
|
|
Response.ContentType = mimeType
|
|
Response.Flush()
|
|
Response.TransmitFile(file.FullName)
|
|
Response.End()
|
|
Catch ex As Exception
|
|
'GuardaLog($"GenerateFile: {ex.ToString()}")
|
|
End Try
|
|
End Sub
|
|
End Class
|